概述
场景:在用pip安装django时提示SSL方面的问题,具体报错如下:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
![查看openssl版本号](https://www.zun.com/zx/wp-content/themes/justnews/themer/assets/images/lazy.png)
思路
系统版本centos7,其中openssl的版本为OpenSSL 1.0.2k-fips 26 Jan 2017,而python3.7需要的openssl的版本为1.0.2或者1.1.x,需要对openssl进行升级,并重新编译python3.7.0,yum 安装的openssl 版本都比较低。
解决过程
1、查看openssl版本
openssl version -a
![查看openssl版本号](https://www.zun.com/zx/wp-content/themes/justnews/themer/assets/images/lazy.png)
2、下贼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
![查看openssl版本号](https://www.zun.com/zx/wp-content/themes/justnews/themer/assets/images/lazy.png)
3、编译安装
./config --prefix=/usr/local/openssl make&& make install
![查看openssl版本号](https://www.zun.com/zx/wp-content/themes/justnews/themer/assets/images/lazy.png)
![查看openssl版本号](https://www.zun.com/zx/wp-content/themes/justnews/themer/assets/images/lazy.png)
4、备份原配置
mv /usr/bin/openssl /usr/bin/openssl.bak mv /usr/include/openssl/ /usr/include/openssl.bak
5、新版配置
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
6、修改系统配置
## 写入openssl库文件的搜索路径 echo "/usr/local/openssl/lib" >> /etc/ld.so.conf ## 使修改后的/etc/ld.so.conf生效 ldconfig -v
7、查看openssl版本
openssl version
![查看openssl版本号](https://www.zun.com/zx/wp-content/themes/justnews/themer/assets/images/lazy.png)
8、重新安装python
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl make && make install ln -fs /usr/local/python/bin/python3.7 /usr/bin/python ln -fs /usr/local/python/bin/pip3 /usr/bin/pip
![查看openssl版本号](https://www.zun.com/zx/wp-content/themes/justnews/themer/assets/images/lazy.png)
9、测试pip功能
pip install django
![查看openssl版本号](https://www.zun.com/zx/wp-content/themes/justnews/themer/assets/images/lazy.png)
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至2705686032@qq.com 举报,一经查实,本站将立刻删除。原文转载: 原文出处: