python 安裝boto3 cannot import name ssl

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:

  1. 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.

  2. In this another server, check if import ssl works. It should work.

  3. 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

  1. Copy this file into the original server. Use the same destination folder: /usr/local/python27/lib/python2.7/lib-dynload/

  2. Double check owner and permissions:

[root@myserver]# chown root:root _ssl.so
[root@myserver]# chmod 755 _ssl.so

  1. 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.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容