Python 3没有名为'_ssl'的模块 [英] Python 3 No module named '_ssl'
问题描述
问题
当我运行python3应用程序时,它显示
While I run you python3 application, it shows
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
I also edited the setup.py file and recomplie 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与路径配置一起编译了
I've complied the openssl with the path configuration
#tar -xzvf openssl-***.tar.gz
#./config --prefix=/usr/local --openssldir=/usr/local/openssl
#make & make install
CentOS 7
CentOS 7
Python 3.6
Python 3.6
推荐答案
我找到了一些解决方案:
I found some solution:
如果使用centos,请尝试:
if you use centos,try:
yum install openssl-devel -y
然后在编译时,附加--with-ssl ,就像这样
then when you compile, append --with-ssl,just like this
./configure prefix=/usr/local/share/python3 --with-ssl
s2
-安装依赖库,进行共享编译流利
s2
-- install depend library, make share compile is fluent
yum install -y zlib zlib-dev openssl-devel sqlite-devel bzip2-devel libffi libffi-devel gcc gcc-c++
wget http://www.openssl.org/source/openssl-1.1.1.tar.gz
tar -zxvf openssl-1.1.1.tar.gz
cd openssl-1.1.1
./config --prefix=$HOME/openssl shared zlib
make && make install
-配置共享ld库路径,以便编译器可以找到它
-- configure shared ld library path so that compile can find it
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/openssl/lib" >> $HOME/.bash_profile
source $HOME/.bash_profile
(zsh用户具有一些不同之处使用.zsh_profile)
-使用openssl路径编译
(zsh user has some different with .zsh_profile) -- compile with openssl path
./configure prefix=/usr/local/share/python3 --with-openssl=$HOME/openssl
这篇关于Python 3没有名为'_ssl'的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!