一、问题说明
故事的起因是我需要安装 virtualenv
开始报错之旅……具体错误截图在另一台PC,因此这里只记录,不展示。
二、解决方案
1、安装python3.8
Ubuntu 14.04 PC默认安装了Python2.7,然后我自己安装过Python3.4;
virtualenv版本需求Python 3.5以上,因此下载Python3.8
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0a2.tgz
tar -xzvf Python-3.8.0a2.tgz
cd Python-3.8
接下来的几点需要注意了
./configure --prefix=/usr/local/python3 --witho-ssl /*prefix 指定安装路径,便以以后卸载,非常重要; --witho-ssl 打开SLL,非常重要*/
make
make install
Python3.8到此安装完毕;再更新软连接就OK啦!
接下来需要更新两个组件
2、安装pip
运行pip提示版本错误,这里有几种情况
如果你的pip版本高于报错需求版本,只需要如下修改即可
sudo gedit /usr/local/python3/bin/pip3
将版本号 "==" 修改为 ">=" 即可
如果你的pip版本低于报错需求版本,需要重新安装pip。
python3.8 需要pip版本为20.3以上。。。
各种更新pip的命令无效,不得不手动寻找资源,手动安装
pip 20.3.1 点击下载
解压后,进入解压目录,你以为安装就可以了吗,不
必须先卸载pip3,然后重新安装,命令如下:
python -m pip uninstall pip /*卸载老旧pip*/
cd pip-20.3
python setup.py build
python setup.py install
/*安装完毕*/
pip3 --version
/*正确输出保本信息代表OK*/
3、更新openssl
前面的坎坷都走了一遍之后,还是一直报
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting virtualenv
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
。。。。。
的错误;
openssl version
/*发现openssl版本是 1.01*/
而python3.8需要openssl 1.2以上,没得说,更新吧。。。。
一顿apt-get install的操作猛如虎。。死活只更新了一个更新包,并未更新版本。
只能手动更新了
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
tar -xvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config --prefix=/usr/local/openssl
make
make install
/*安装成功*/
/*备份系统openssl,以免造成无法挽回的后果*/
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl /usr/include/openssl.bak
/*配置软连接至新版本*/
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
/*写入openssl库文件的搜索路径*/
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
/*使修改后的/etc/ld.so.conf生效*/
ldconfig -v
openssl version
/*正常显示新版本号*/
4、必看重点
好不容易走到这里,你以为就结束了?
需要重新安装一遍python。。。
/*配置命令修改为*/
./configure --profix=/usr/local/python3 --with-openssl=/usr/local/openssl
make
make install
引用地址:
https://blog.csdn.net/weixin_38933763/article/details/111173027
文章评论