ubuntu下安裝python3.6.5導入ssl模塊失敗


1、問題

python安裝完畢后,提示找不到ssl模塊:
[root@localhost ~]# python3
Python 3.6.5 (default, Jun 3 2018, 11:08:43) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
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/python27/lib/python2.7/ssl.py", line 60, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: No module named _ssl
>>>

2、解決

修改Python-3.6.5文件夾中的/Moudes/Setup.dict

# Socket module helper for socket(2)
_socket socketmodule.c timemodule.c    #去除該行注釋(備注)

# 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         #去除該行注釋(備注)

重新編譯

make
sudo make install

再進入python3交互模式,import ssl就可以了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM