Python教程

python2.7极速升级python3.7

本文主要是介绍python2.7极速升级python3.7,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

下载python压缩包

环境:centos7

下载编译好的python3压缩包

并解压

cd /usr/local
wget  https://bgcc.cc/download/python3-7-usr-local.tar.gz
tar xf python3-7-usr-local.tar.gz

升级python

配置保留本机python2.7并升级到python3.7

rm -f /usr/bin/python
sed -i 's/\/usr\/bin\/python/\/usr\/bin\/python2.7/' /usr/bin/yum
sed -i 's/\/usr\/bin\/python/\/usr\/bin\/python2.7/' /usr/libexec/urlgrabber-ext-down
ln -s /usr/local/python3/bin/python3 /usr/bin/python -f
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip -f

配置

配置国内pip下载源

cd /root
mkdir .pip
cd .pip
cat >pip.conf<<EOF
[global]
index-url = http://pypi.douban.com/simple
[install]
use-mirrors =true
mirrors =http://pypi.douban.com/simple/
trusted-host =pypi.douban.com
EOF

升级pip

升级pip

pip install --upgrade pip

配置环境

# cat  >> /etc/profile <<EOF
PATH=$PATH:/usr/local/python3/bin/
export PATH
EOF
# source /etc/profile
这篇关于python2.7极速升级python3.7的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!