更改Ubuntu默认python版本的两种方法python-> Anaconda

部署运行你感兴趣的模型镜像

转载自:更改Ubuntu默认python版本的两种方法python-> Anaconda

你可以按照以下方法使用 ls 命令来查看你的系统中都有那些 Python 的二进制文件可供使用。

?
1
2
$ ls /usr/bin/python *
/usr/bin/python /usr/bin/python2 /usr/bin/python2 .7 /usr/bin/python3 /usr/bin/python3 .4 /usr/bin/python3 .4m /usr/bin/python3m

执行如下命令查看默认的 Python 版本信息:

?
1
2
$ python --version
Python 2.7.8

1、基于用户修改 Python 版本:

想要为某个特定用户修改 Python 版本,只需要在其 home 目录下创建一个 alias(别名) 即可。打开该用户的 ~/.bashrc文件,添加新的别名信息来修改默认使用的 Python 版本。

alias pythpn ='这里放你想默认的python的地址'
1.
$ alias python= '/usr/bin/python3.4'

一旦完成以上操作,重新登录或者重新加载 .bashrc 文件,使操作生效。

?
1
$ . ~/.bashrc

检查当前的 Python 版本。

?
1
2
$ python --version
Python 3.4.2

2、 在系统级修改 Python 版本

我们可以使用 update-alternatives 来为整个系统更改 Python 版本。以 root 身份登录,首先罗列出所有可用的 python 替代版本信息:

?
1
2
# update-alternatives --list python
update-alternatives: error: no alternatives for python

如果出现以上所示的错误信息,则表示 Python 的替代版本尚未被 update-alternatives 命令识别。想解决这个问题,我们需要更新一下替代列表,将 python2.7 和 python3.4 放入其中。

?
1
2
3
4
# 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
# update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2
update-alternatives: using /usr/bin/python3 .4 to provide /usr/bin/python (python) in auto mode

--install 选项使用了多个参数用于创建符号链接。最后一个参数指定了此选项的优先级,如果我们没有手动来设置替代选项,那么具有最高优先级的选项就会被选中。这个例子中,我们为 /usr/bin/python3.4 设置的优先级为2,所以update-alternatives 命令会自动将它设置为默认 Python 版本。

?
1
2
# python --version
Python 3.4.2

接下来,我们再次列出可用的 Python 替代版本。

?
1
2
3
# update-alternatives --list python
/usr/bin/python2 .7
/usr/bin/python3 .4

现在开始,我们就可以使用下方的命令随时在列出的 Python 替代版本中任意切换了。

?
1
# update-alternatives --config python

?
1
2
# python --version
Python 2.7.8

3、移除替代版本

一旦我们的系统中不再存在某个 Python 的替代版本时,我们可以将其从 update-alternatives 列表中删除掉。例如,我们可以将列表中的 python2.7 版本移除掉。

?
1
2
3
4
# update-alternatives --remove python /usr/bin/python2.7
 
update-alternatives: removing manually selected alternative - switching python to auto mode
update-alternatives: using /usr/bin/python3 .4 to provide /usr/bin/python (python) in auto mode

方法2、移除软连接

?
1
2
3
rm -rf /data/logs
 
ln -s /temp/logs /data/logs

解决软连接ln报错-bash: /usr/local/bin/mysql: Too many levels of symbolic links

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

ERROR: Ignored the following versions that require a different python version: 0.6.0.dev0 Requires-Python >=3.9; 0.6.0rc0 Requires-Python >=3.9; 0.6.1 Requires-Python >=3.9; 0.6.1rc0 Requires-Python >=3.9; 0.6.2 Requires-Python >=3.9; 0.7.0 Requires-Python >=3.9; 0.7.0.dev0 Requires-Python >=3.9; 0.7.0rc0 Requires-Python >=3.9; 0.7.0rc1 Requires-Python >=3.9; 1.0.0 Requires-Python >=3.9.0; 1.0.0rc0 Requires-Python >=3.9.0; 1.0.0rc1 Requires-Python >=3.9.0; 1.0.0rc2 Requires-Python >=3.9.0; 1.0.0rc3 Requires-Python >=3.9.0; 1.0.0rc4 Requires-Python >=3.9.0; 1.0.0rc5 Requires-Python >=3.9.0; 1.0.0rc6 Requires-Python >=3.9.0; 1.0.0rc7 Requires-Python >=3.9.0; 1.0.1 Requires-Python >=3.9.0; 1.1.0 Requires-Python >=3.9.0; 1.1.0rc0 Requires-Python >=3.9.0; 1.1.0rc1 Requires-Python >=3.9.0; 1.1.0rc2 Requires-Python >=3.9.0; 1.1.1 Requires-Python >=3.9.0; 1.1.2 Requires-Python >=3.9.0; 1.1.3 Requires-Python >=3.9.0; 1.1.4 Requires-Python >=3.9.0; 1.1.5 Requires-Python >=3.9.0; 1.11.0 Requires-Python <3.13,>=3.9; 1.11.0rc1 Requires-Python <3.13,>=3.9; 1.11.0rc2 Requires-Python <3.13,>=3.9; 1.11.1 Requires-Python <3.13,>=3.9; 1.11.2 Requires-Python <3.13,>=3.9; 1.11.3 Requires-Python <3.13,>=3.9; 1.11.4 Requires-Python >=3.9; 1.12.0 Requires-Python >=3.9; 1.12.0rc1 Requires-Python >=3.9; 1.12.0rc2 Requires-Python >=3.9; 1.13.0 Requires-Python >=3.9; 1.13.0rc1 Requires-Python >=3.9; 1.13.1 Requires-Python >=3.9; 1.14.0 Requires-Python >=3.10; 1.14.0 Requires-Python >=3.9; 1.14.0rc1 Requires-Python >=3.10; 1.14.0rc1 Requires-Python >=3.9; 1.14.0rc2 Requires-Python >=3.10; 1.14.0rc2 Requires-Python >=3.9; 1.14.1 Requires-Python >=3.10; 1.15.0 Requires-Python >=3.10; 1.15.0rc1 Requires-Python >=3.10; 1.15.0rc2 Requires-Python >=3.10; 1.15.1 Requires-Python >=3.10; 1.15.2 Requires-Python >=3.10; 1.15.3 Requires-Python >=3.10; 1.16.0 Requires-Python >=3.11; 1.16.0rc1 Requires-Python >=3.11; 1.16.0rc2 Requires-Python >=3.11; 1.16.1 Requires-Python >=3.11; 1.16.2 Requires-Python >=3.11; 1.16.3 Requires-Python >=3.11; 1.2.0 Requires-Python >=3.9; 1.2.1 Requires-Python >=3.9; 1.2.1rc1 Requires-Python >=3.9; 1.25.0 Requires-Python >=3.9; 1.25.1 Requires-Python >=3.9; 1.25.2 Requires-Python >=3.9; 1.26.0 Requires-Python <3.13,>=3.9; 1.26.1 Requires-Python <3.13,>=3.9; 1.26.2 Requires-Python >=3.9; 1.26.3 Requires-Python >=3.9; 1.26.4 Requires-Python >=3.9; 1.3.0 Requires-Python >=3.9; 1.3.1 Requires-Python >=3.10; 1.3.2 Requires-Python >=3.10; 1.3.3 Requires-Python >=3.11; 1.4.0a4 Requires-Python >=3.9; 1.4.0a5 Requires-Python >=3.9; 1.4.0a6 Requires-Python >=3.9; 1.4.0a7 Requires-Python >=3.9; 1.4.0a8 Requires-Python >=3.9; 1.4.0b1 Requires-Python >=3.9; 1.4.0b2 Requires-Python >=3.9; 1.4.10rc0 Requires-Python >=3.10; 1.4.8 Requires-Python >=3.10; 1.4.9 Requires-Python >=3.10; 1.71.0 Requires-Python >=3.9; 1.71.0rc2 Requires-Python >=3.9; 1.71.2 Requires-Python >=3.9; 1.72.0 Requires-Python >=3.9; 1.72.0rc1 Requires-Python >=3.9; 1.72.1 Requires-Python >=3.9; 1.72.2 Requires-Python >=3.9; 1.73.0 Requires-Python >=3.9; 1.73.0rc1 Requires-Python >=3.9; 1.73.1 Requires-Python >=3.9; 1.74.0 Requires-Python >=3.9; 1.74.0rc1 Requires-Python >=3.9; 1.75.0 Requires-Python >=3.9; 1.75.0rc1 Requires-Python >=3.9; 1.75.1 Requires-Python >=3.9; 1.76.0 Requires-Python >=3.9; 1.76.0rc1 Requires-Python >=3.9; 11.0.0 Requires-Python >=3.9; 11.1.0 Requires-Python >=3.9; 11.2.1 Requires-Python >=3.9; 11.3.0 Requires-Python >=3.9; 12.0.0 Requires-Python >=3.10; 2.0.0 Requires-Python >=3.9; 2.0.1 Requires-Python >=3.9; 2.0.2 Requires-Python >=3.9; 2.1.0 Requires-Python >=3.10; 2.1.0 Requires-Python >=3.9; 2.1.0rc0 Requires-Python >=3.9; 2.1.1 Requires-Python >=3.10; 2.1.1 Requires-Python >=3.9; 2.1.2 Requires-Python >=3.10; 2.1.2 Requires-Python >=3.9; 2.1.3 Requires-Python >=3.10; 2.1.3 Requires-Python >=3.9; 2.1.4 Requires-Python >=3.9; 2.14.1 Requires-Python >=3.9; 2.15.0 Requires-Python >=3.9; 2.15.1 Requires-Python >=3.9; 2.15.2 Requires-Python >=3.9; 2.16.0 Requires-Python >=3.9; 2.16.1 Requires-Python >=3.9; 2.16.2 Requires-Python >=3.9; 2.17.0 Requires-Python >=3.9; 2.17.1 Requires-Python >=3.9; 2.18.0 Requires-Python >=3.9; 2.19.0 Requires-Python >=3.9; 2.2.0 Requires-Python >=3.10; 2.2.0 Requires-Python >=3.9; 2.2.0rc0 Requires-Python >=3.9; 2.2.1 Requires-Python >=3.10; 2.2.1 Requires-Python >=3.9; 2.2.2 Requires-Python >=3.10; 2.2.2 Requires-Python >=3.9; 2.2.3 Requires-Python >=3.10; 2.2.3 Requires-Python >=3.9; 2.2.4 Requires-Python >=3.10; 2.2.5 Requires-Python >=3.10; 2.2.6 Requires-Python >=3.10; 2.20.0 Requires-Python >=3.9; 2.3.0 Requires-Python >=3.11; 2.3.0 Requires-Python >=3.9; 2.3.1 Requires-Python >=3.11; 2.3.1 Requires-Python >=3.9; 2.3.2 Requires-Python >=3.11; 2.3.2 Requires-Python >=3.9; 2.3.3 Requires-Python >=3.11; 2.3.3 Requires-Python >=3.9; 2.3.4 Requires-Python >=3.11; 2.3.5 Requires-Python >=3.11; 2.32.5 Requires-Python >=3.9; 2.5.0 Requires-Python >=3.9; 2025.10.0 Requires-Python >=3.9; 2025.10.22 Requires-Python >=3.9; 2025.10.23 Requires-Python >=3.9; 2025.11.3 Requires-Python >=3.9; 2025.3.2 Requires-Python >=3.9; 2025.5.0 Requires-Python >=3.9; 2025.5.1 Requires-Python >=3.9; 2025.7.0 Requires-Python >=3.9; 2025.7.31 Requires-Python >=3.9; 2025.7.33 Requires-Python >=3.9; 2025.7.34 Requires-Python >=3.9; 2025.8.29 Requires-Python >=3.9; 2025.9.0 Requires-Python >=3.9; 2025.9.1 Requires-Python >=3.9; 2025.9.18 Requires-Python >=3.9; 25.1 Requires-Python >=3.9; 25.1.1 Requires-Python >=3.9; 25.2 Requires-Python >=3.9; 25.3 Requires-Python >=3.9; 3.0.0 Requires-Python >=3.9; 3.0.1 Requires-Python >=3.9; 3.0.2 Requires-Python >=3.9; 3.0.3 Requires-Python >=3.9; 3.1.0 Requires-Python >=3.9; 3.10 Requires-Python >=3.10; 3.10.0 Requires-Python >=3.10; 3.10.0rc1 Requires-Python >=3.10; 3.10.1 Requires-Python >=3.10; 3.10.3 Requires-Python >=3.10; 3.10.5 Requires-Python >=3.10; 3.10.6 Requires-Python >=3.10; 3.10.7 Requires-Python >=3.10; 3.12.0 Requires-Python >=3.9; 3.13.0 Requires-Python >=3.9; 3.14.0 Requires-Python >=3.9; 3.15.0 Requires-Python >=3.9; 3.15.1 Requires-Python >=3.9; 3.16.0 Requires-Python >=3.9; 3.17.0 Requires-Python >=3.10; 3.17.0 Requires-Python >=3.9; 3.18.0 Requires-Python >=3.9; 3.19.1 Requires-Python >=3.9; 3.2 Requires-Python >=3.9; 3.2.0 Requires-Python >=3.10; 3.2.0 Requires-Python >=3.9; 3.2.0b1 Requires-Python >=3.9; 3.2.0b2 Requires-Python >=3.9; 3.2.0b3 Requires-Python >=3.9; 3.2.0rc1 Requires-Python >=3.9; 3.2.1 Requires-Python >=3.9; 3.2.2 Requires-Python >=3.9; 3.2.3 Requires-Python >=3.9; 3.2.4 Requires-Python >=3.9; 3.2.5 Requires-Python >=3.9; 3.20.0 Requires-Python >=3.10; 3.2rc0 Requires-Python >=3.9; 3.3 Requires-Python >=3.10; 3.3.0a1 Requires-Python >=3.9; 3.3.0b1 Requires-Python >=3.9; 3.3rc0 Requires-Python >=3.10; 3.4 Requires-Python >=3.10; 3.4.1 Requires-Python >=3.10; 3.4.2 Requires-Python >=3.10; 3.4rc0 Requires-Python >=3.10; 3.5 Requires-Python >=3.11; 3.5rc0 Requires-Python >=3.11; 3.6 Requires-Python >=3.11; 3.6rc0 Requires-Python >=3.11; 3.8 Requires-Python >=3.9; 3.8.0 Requires-Python >=3.9; 3.8.0rc1 Requires-Python >=3.9; 3.8.1 Requires-Python >=3.9; 3.8.2 Requires-Python >=3.9; 3.8.3 Requires-Python >=3.9; 3.8.4 Requires-Python >=3.9; 3.9 Requires-Python >=3.9; 3.9.0 Requires-Python >=3.9; 3.9.0rc2 Requires-Python >=3.9; 3.9.1 Requires-Python >=3.9; 3.9.1.post1 Requires-Python >=3.9; 3.9.2 Requires-Python >=3.9; 3.9.3 Requires-Python >=3.9; 3.9.4 Requires-Python >=3.9; 4.0.0 Requires-Python >=3.10; 4.58.0 Requires-Python >=3.9; 4.58.1 Requires-Python >=3.9; 4.58.2 Requires-Python >=3.9; 4.58.3 Requires-Python >=3.9; 4.58.4 Requires-Python >=3.9; 4.58.5 Requires-Python >=3.9; 4.59.0 Requires-Python >=3.9; 4.59.1 Requires-Python >=3.9; 4.59.2 Requires-Python >=3.9; 4.60.0 Requires-Python >=3.9; 4.60.1 Requires-Python >=3.9; 6.0.0 Requires-Python >=3.9; 6.1.0 Requires-Python >=3.9; 6.2.0 Requires-Python >=3.9; 6.2.1 Requires-Python >=3.9; 6.2.2 Requires-Python >=3.9; 6.30.0 Requires-Python >=3.9; 6.30.0rc1 Requires-Python >=3.9; 6.30.0rc2 Requires-Python >=3.9; 6.30.1 Requires-Python >=3.9; 6.30.2 Requires-Python >=3.9; 6.31.0 Requires-Python >=3.9; 6.31.0rc1 Requires-Python >=3.9; 6.31.0rc2 Requires-Python >=3.9; 6.31.1 Requires-Python >=3.9; 6.32.0 Requires-Python >=3.9; 6.32.0rc1 Requires-Python >=3.9; 6.32.0rc2 Requires-Python >=3.9; 6.32.1 Requires-Python >=3.9; 6.33.0 Requires-Python >=3.9; 6.33.0rc1 Requires-Python >=3.9; 6.33.0rc2 Requires-Python >=3.9; 6.33.1 Requires-Python >=3.9; 6.5.0 Requires-Python >=3.9; 6.5.1 Requires-Python >=3.9; 6.5.2 Requires-Python >=3.9; 75.4.0 Requires-Python >=3.9; 75.5.0 Requires-Python >=3.9; 75.6.0 Requires-Python >=3.9; 75.7.0 Requires-Python >=3.9; 75.8.0 Requires-Python >=3.9; 75.8.1 Requires-Python >=3.9; 75.8.2 Requires-Python >=3.9; 75.9.0 Requires-Python >=3.9; 75.9.1 Requires-Python >=3.9; 76.0.0 Requires-Python >=3.9; 76.1.0 Requires-Python >=3.9; 77.0.1 Requires-Python >=3.9; 77.0.3 Requires-Python >=3.9; 78.0.1 Requires-Python >=3.9; 78.0.2 Requires-Python >=3.9; 78.1.0 Requires-Python >=3.9; 78.1.1 Requires-Python >=3.9; 79.0.0 Requires-Python >=3.9; 79.0.1 Requires-Python >=3.9; 8.2.0 Requires-Python >=3.10; 8.2.1 Requires-Python >=3.10; 8.2.2 Requires-Python >=3.10; 8.3.0 Requires-Python >=3.10; 8.3.1 Requires-Python >=3.10; 8.6.0 Requires-Python >=3.9; 8.6.1 Requires-Python >=3.9; 8.7.0 Requires-Python >=3.9; 80.0.0 Requires-Python >=3.9; 80.0.1 Requires-Python >=3.9; 80.1.0 Requires-Python >=3.9; 80.2.0 Requires-Python >=3.9; 80.3.0 Requires-Python >=3.9; 80.3.1 Requires-Python >=3.9; 80.4.0 Requires-Python >=3.9; 80.6.0 Requires-Python >=3.9; 80.7.0 Requires-Python >=3.9; 80.7.1 Requires-Python >=3.9; 80.8.0 Requires-Python >=3.9; 80.9.0 Requires-Python >=3.9 ERROR: Could not find a version that satisfies the requirement torch==2.0.0+cu118 (from versions: 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1, 2.0.0, 2.0.1, 2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, 2.4.1) ERROR: No matching distribution found for torch==2.0.0+cu118
最新发布
11-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值