将Python从2.7升级至3.5
2021/07/12 09:38
教程
1、升级Python到3.5,在官网下载Python,然后安即可
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz tar -xJvf Python-3.5.1.tar.xz cd Python-3.5.1 ./configure --prefix=/usr/local make make altinstall
2、update-alternatives切换版本
建立python的组, 添加Python2和Python3的可选项
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2 # 添加Python2可选项,优先级为2 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1 #添加Python3可选项,优先级为1
3、查看当前配置
sudo update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/python2.7 2 auto mode * 1 /usr/bin/python2.7 2 manual mode 2 /usr/bin/python3.5 1 manual mode Press <enter> to keep the current choice[*], or type selection number:
4、按2,即可切换成3.5版本
2 update-alternatives: using /usr/bin/python3.5 to provide /usr/bin/python (python) in manual mode
5、此时再查询
python -V Python 3.5.3
留言评论