问题
当我运行python3应用程序时,它显示
File "/usr/local/lib/python3.6/ssl.py", line 101, in <module>
import _ssl # if we can't import it, let the error propagate
ModuleNotFoundError: No module named '_ssl'
我尝试过的
安装依赖项
yum install openssl-devel
我还编辑了setup.py文件并重新编译python3
# Detect SSL support for the socket module (via _ssl)
search_for_ssl_incs_in = [
'/usr/local/ssl/include',
'/usr/local/include/openssl', #I've added this line
'/usr/contrib/ssl/include/'
]
我已经将openssl与路径配置一起编译了
#tar -xzvf openssl-***.tar.gz
#./config --prefix=/usr/local --openssldir=/usr/local/openssl
#make & make install
CentOS的7
Python 3.6
解决方法:
我遇到了同样的问题,我从源代码安装了python,并且在编译时未启用ssl选项.因此,我在以下article中找到了解决方案.您需要找到ssl部分Modules / Setup.dist并取消对该部分的注释.希望这会帮助某人.