python 安裝完boto3 后,測試import boto3
報錯 缺少模塊cannot import name ssl
網(wǎng)上大部分說要重裝python,編譯安裝時指定ssl ,理論上來說應(yīng)該是編譯安裝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.