centOS7安装python3.7 pip3 python2与python3共存
下载文件
wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgz
解压
tar zxvf Python-3.7.8.tgz
安装所需依赖
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel zlib-devel ncurses-devel tk-devel libffi-devel gcc make
进入目录
cd Python-3.7.8
必须加上--with-ssl (如果不带ssl可能会导致后面pip链接网络失败,也就安装不了python的其他的包了。而使用ssl之前一定要先安装openssl-devel)
./configure --prefix=/usr/local/python3 --with-ssl
make
make install
注意设置软链时用/usr/bin/python3 不要设置成python 不然会合和python2冲突
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
验证版本号
python3 -V
pip3 -V
评论已关闭