Ubuntu 安装python3及多版本切换详解编程语言
2023-06-13 09:11:53 时间
2.使用 update-alternatives 来为整个系统更改Python 版本
查看python替代版本信息
~$ update-alternatives --display python
但是结果为
update-alternatives: error: no alternatives for python
python的替代版本尚未被update-alternatives
查看python的位置
$ whereis python python: /usr/bin/python2.7 /usr/bin/python3.7 /usr/bin/python3.5m /usr/bin/python3.7m /usr/bin/python3.5 /usr/bin/python /usr/lib/python2.7 /usr/lib/python3.7 /usr/lib/python3.5 /etc/python2.7 /etc/python3.7 /etc/python3.5 /etc/python /usr/local/lib/python2.7 /usr/local/lib/python3.7 /usr/local/lib/python3.5 /usr/share/python /usr/share/man/man1/python.1.gz
更新一下替代列表
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode [email protected]:~$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2 update-alternatives: using /usr/bin/python3.7 to provide /usr/bin/python (python) in auto mode
查看python替代版本信息
$ update-alternatives --display python python - auto mode link best version is /usr/bin/python3.7 link currently points to /usr/bin/python3.7 link python is /usr/bin/python /usr/bin/python2.7 - priority 1 /usr/bin/python3.7 - priority 2
查看python版本
$ python -V Python 3.7.9
3.切换版本
切换到2.7
$ sudo update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.7 2 auto mode 1 /usr/bin/python2.7 1 manual mode 2 /usr/bin/python3.7 2 manual mode Press enter to keep the current choice[*], or type selection number: 1 update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode [email protected]:~$ python -V Python 2.7.12
pip版本
$ pip -V pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
切换到3.7
sudo update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/python3.7 2 auto mode * 1 /usr/bin/python2.7 1 manual mode 2 /usr/bin/python3.7 2 manual mode Press enter to keep the current choice[*], or type selection number: 2 update-alternatives: using /usr/bin/python3.7 to provide /usr/bin/python (python) in manual mode [email protected]:~$ python -V Python 3.7.9
安装pip
sudo apt install python3-pip
pip版本
pip -V pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.7)
pip的版本随着python版本切换
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/20446.html
cjavapython相关文章
- pycharm怎么安装requests模块_python3安装模块
- python pyquery_python3解析库pyquery
- Python3 多进程与多线程
- Ubuntu下安装Python3和IDLE3
- Linux上安装python3
- 【技术分享】Python3升级pip3[通俗易懂]
- murmurhash2算法python3版本
- centos7安装python3.8_centos python3安装
- Linux下一键安装Python3&更改镜像源&虚拟环境管理技巧
- python suds_在python3.x上安装suds 并访问webservice「建议收藏」
- python3 牛客网:OJ在线编程常见输入输出练习(ACM模式)
- CentOS python3 & Java 安装
- linux保留旧版本python,安装python3详解程序员
- Python3.x:Linux下安装python3.6详解程序员
- python3使用urllib示例详解编程语言
- python3 连接sqlite实例详解编程语言
- python3 开发面试题(面向对象)6.6详解编程语言
- python3 开发面试题(装饰器必须考)6.4详解编程语言
- Python3.x:函数定义详解编程语言
- Python3.x:os.chdir(改变当前路径方法)介绍详解编程语言
- Ubuntu安装MySQL数据库的指南(ubuntu装mysql)
- 安装Ubuntu系统,轻松使用Oracle(ubuntu安装oracle)
- 「Ubuntu上安装Redis:步骤指南」(ubuntu安装redis)
- Python3实现生成随机密码的方法