Python安装后找不到ssl模块怎么办,如何处理
在这篇文章中,我们来学习一下“Python安装后找不到ssl模块怎么办,如何处理”的相关知识,下文有详细的讲解,易于大家学习和理解,有需要的朋友可以借鉴参考,下面就请大家跟着小编的思路一起来学习一下吧。
“Python安装后找不到ssl模块怎么办,如何处理”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业技术相关的知识可以关注博信网站,小编每天都会为大家更新不同的知识。
python安装完毕后,提示找不到ssl模块:
[www@pythontab.com~]$python Python2.7.15(default,Oct232018,18:08:43) [GCC4.4.720120313(RedHat4.4.7-23)]onlinux2 Type"help","copyright","credits"or"license"formoreinformation. >>>importssl Traceback(mostrecentcalllast): File"<stdin>",line1,in<module> File"/usr/local/python27/lib/python2.7/ssl.py",line60,in<module> import_ssl#ifwecan'timportit,lettheerrorpropagate ImportError:Nomodulenamed_ssl >>>
解决方法:
1. 查看openssl安装包,发现缺少openssl-devel包
[www@pythontab.com~]$rpm-aq|grepopenssl openssl-0.9.8e-20.el5 openssl-0.9.8e-20.el5 [www@pythontab.com~]$
2. yum安装openssl-devel
[www@pythontab.com~]$yuminstallopenssl-devel-y #查看安装结果 [www@pythontab.com~]$rpm-aq|grepopenssl openssl-devel-1.0.1e-57.el6.x86_64 openssl-1.0.1e-57.el6.x86_64
3. 重新编译python
修改Setup文件
vi/src/Python-2.7.15/Modules/Setup
修改结果如下:
#Socketmodulehelperforsocket(2) _socketsocketmodule.ctimemodule.c #SocketmodulehelperforSSLsupport;youmustcommentouttheother #socketlineabove,andpossiblyedittheSSLvariable: #SSL=/usr/local/ssl _ssl_ssl.c\ -DUSE_SSL-I$(SSL)/include-I$(SSL)/include/openssl\ -L$(SSL)/lib-lssl-lcrypto
4. 重新编译
进入源码目录,重新编译安装
[www@pythontab.com~]$cd/src/Python-2.7.15/ [www@pythontab.com~]$make [www@pythontab.com~]$makeinstall
5. 测试,已可正常使用。
[www@pythontab.com~]$python Python2.7.15(default,Oct232018,19:08:43) [GCC4.4.720120313(RedHat4.4.7-23)]onlinux2 Type"help","copyright","credits"or"license"formoreinformation. >>>importssl >>>
“Python安装后找不到ssl模块怎么办,如何处理”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业技术相关的知识可以关注博信网站,小编每天都会为大家更新不同的知识。
版权声明
本文仅代表作者观点,不代表博信信息网立场。
上一篇:Oracle11g引用分区表有什么作用 下一篇:SQL中索引怎么用