pip安装第三方包出现ssl错误的解决方法

版权声明:转载注明出处,大家一起交流 https://blog.csdn.net/qq_38231051/article/details/82430954

我的情况是这样的

centos7系统,内置python2.7,python3.4,(后来加上自己又安装了一个python3.6)

pip安装第三方包时,用pip2可以安装,没有报错。

pip3安装会报ssl错误。

python3控制台中import ssl报错。


因为个人解决的时候试了很多种方法,所以具体有哪几个步骤才是关键的我也不是很清楚。但总的来看有这些地方。

首先记得安装相关的依赖包。(这个在网上很容易找到)

1、查找_ssl.so文件(因为我的python2是没问题的所以可以在python2中找到这个文件),把他拷到python3相应的位置。

这时就可以看到在python3的控制台下可以顺利的导入ssl模块。

2、修改Modules文件夹下的Setup文件:

# Socket module helper for socket(2)
_socket socketmodule.c

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/etc/ssl
_ssl _ssl.c \
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
        -L$(SSL)/lib -lssl -lcrypto

3、编译(重新编译)的时候,需要加上ssl选项,具体命令

./configure --with-ssl
make
sudo make install

希望这个教程能够帮助到你。

猜你喜欢

转载自blog.csdn.net/qq_38231051/article/details/82430954
今日推荐