pip install 安装gevernt 报错pip is configured with locations that require TLS/SSL, however the ssl modul

背景:python文件中引用了gevent库  部署到linux服务器后提示nomodel name gevent   所以想要使用pip进行安装,但安装pip的时候提示:pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

大概意思就是pip没有ssl模块  所以无法安装

尝试:使用python2.7

import ssl

没有报错。说明openssl已经安装了  只是python3中没有  那好办 重新安装python3就好了

进入解压后的Python目录

cd Python-3.6.1
./configure -prefix=/usr/local/python3
./configure --with-openssl=/usr/local/openssl
make
make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

安装后使用python3  进入python环境  输入import ssl   还是提示没有_ssl模块

此时就纳闷了  怎么回事明明已经安装了啊

又查阅资料:提示有可能因为openssl版本较低,一看果然openssl的版本为OpenSSL 1.0.1e-fips 11 Feb 2013   而python3需要openssl的版本为1.0.2或者1.1.x,需要对openssl进行升级

升级openssl
# 1.下贼openssl
wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
tar -zxvf openssl-1.1.1a.tar.gz
cd openssl-1.1.1a
# 2.编译安装
./config --prefix=/usr/local/openssl no-zlib #不需要zlib
make
make install
# 3.备份原配置
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl/ /usr/include/openssl.bak
# 4.新版配置
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# 5.修改系统配置
## 写入openssl库文件的搜索路径
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
## 使修改后的/etc/ld.so.conf生效
ldconfig -v
# 6.查看openssl版本
openssl version

openssl version 提示:

/usr/local/openssl/bin/openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory

假如你的libssl.so.1.1 文件在/usr/local/openssl/lib/下面,可以这样做

ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1

ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1

3.3 重新安装python
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
make
make install

一顿操作后 发现 import ssl还是报错   我就蒙了

最后发现是python版本不匹配,现在用的是python3.6.1  升级到python3.7.1就好了

python3.7安装, 解决pip is configured with locations that require TLS/SSL问题
1.安装相关依赖

yum install gcc libffi-devel zlib* openssl-devel libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make -y


2.下载并解压
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
# 下载
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
# 解压并编译:
tar -xvJf Python-3.7.1.tar.xz
cd Python-3.7.1

3.编译安装
./configure prefix=/usr/local/python3
make && make install
# 编译完成后,创建软链接文件到执行文件路径:
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
# 我们可以清除之前编译的可执行文件及配置文件 && 清除所有生成的文件:
make clean && make distclean

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值