python 安装boto3 cannot import name ssl

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:

  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.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容