python 安装完boto3 后,测试import boto3
报错 缺少模块cannot import name ssl
网上大部分说要重装python,编译安装时指定ssl ,理论上来说应该是编译安装python 前,要安装
openssl-devel 这个包的,编译安装python 后 就不用再指定,会自动找到。
因为机器上有脚本在跑,不能重装python ,在ss 上找到一偏方:
在类似的的机器上找到_ssl.so 文件,放到/usr/local/python/lib/python2.7/lib-dynload/_ssl.so
I had exactly the same problem. I fixed it without rebuilding python, as follows:
Find another server with the same architecture (i386 or x86_64) and the same python version (example: 2.7.5). Yes, this is the hard part. You can try installing python from sources into another server if you can't find any server with the same python version.
In this another server, check if import ssl works. It should work.
If it works, then try to find the _ssl lilbrary as follows:
[root@myserver]# find / -iname _ssl.so
/usr/local/python27/lib/python2.7/lib-dynload/_ssl.so
Copy this file into the original server. Use the same destination folder: /usr/local/python27/lib/python2.7/lib-dynload/
Double check owner and permissions:
[root@myserver]# chown root:root _ssl.so
[root@myserver]# chmod 755 _ssl.so
- Now you should be able to import ssl.
This worked for me in a CentOS 6.3 x86_64 environment with python 2.7.3. Also I had python 2.6.6 installed, but with ssl working fine.
Hope it helps.