无法在python3.6中导入ssl:ModuleNotFoundError:没有名为'_ssl'的模块

时间:2018-05-10 01:34:17

标签: python python-3.x ssl openssl python-import

我从源代码安装了python 3.6。 Python似乎工作正常,但我无法导入openssl 1.1.1(我需要使用的预发行版)。我认为存在路径问题,但不确定。当我尝试从python导入ssl时,这是我得到的输出:

information_schema.TABLES

有什么建议吗?

当我安装openssl时,我抓住了source code然后:

~/Downloads/Python-3.6.5$ python3
Python 3.6.5 (default, May  9 2018, 15:43:39) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  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' 

似乎openssl已正确安装。输出大致类似于此路径:

./config
sudo make
sudo make install 

我然后在/usr/local/share/man/man5/config.5

中取消注释这两行
Python-3.6.5/Module/Setup.dist

并且

_socket socketmodule.c

然后,当我尝试在python中导入ssl时,我收到此错误:

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:

SSL=/usr/local/ssl
_ssl _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib -lssl -lcrypto
你能帮帮忙吗?可能是问题的原因是什么?

0 个答案:

没有答案