本站使用了 Pjax 等基于 JavaScript 的开发技术,但您的浏览器已禁用 JavaScript,请开启 JavaScript 以保证网站正常显示!

将Python从2.7升级至3.5

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

python -V
Python 3.5.3



 继续浏览关于 的文章

 本文最后更新于:2022/05/03 11:21:26,可能因经年累月而与现状有所差异

 引用转载请注明:Dong's blog > 技术分享 > 将Python从2.7升级至3.5