Article turned from: http://write.blog.csdn.net/postedit/51725016
1. Testing
[[email protected] ~]# python
Python 2.7.8 (default, June 17 2016, 01:25:39)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import SSL
Traceback (most recent):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/ssl.py", line A, in <module>
Import _ssl # If we can ' t import it, let the error propagate
Importerror:no module named _ssl
2. View
[email protected] ~]# Yum List installed | grep SSL
openssl.x86_64 1.0.0-27.el6 @anaconda-centos-201303020151.x86_64/6.4
3. Installation
[email protected] ~]# Yum install openssl-devel-y
4. View Results
[Email protected] ~]# Rpm-aq|grep OpenSSL
Openssl-1.0.1e-48.el6_8.1.x86_64
Openssl-devel-1.0.1e-48.el6_8.1.x86_64
5. Recompile python
#修改Setup文件
Vi/usr/software/python-2.7.5/modules/setup
#修改结果如下:
# Socket Module Helper for Socket (2)
_socket socketmodule.c timemodule.c
# Socket Module helper for SSL support; You must comment out of 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
6. Recompile
Make
Make install
7. Test results
[[email protected] ~]# python
Python 2.7.8 (default, June 21 2016, 17:51:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import _ssl
>>> exit ()
(GO) input pipt hint: attributeerror: ' Module ' object has no attribute ' httpsconnection '