我试图在CentOS 6上将python配置为3.9。
以下是我的步骤:
[root@quickstart ~]# alternatives --install /usr/bin/python python /usr/local/bin/python3.9 10
[root@quickstart ~]# alternatives --config python
There is 1 program that provides 'python'.
Selection Command
-----------------------------------------------
*+ 1 /usr/local/bin/python3.9
Enter to keep the current selection[+], or type selection number: 1
[root@quickstart ~]# alternatives --display python
python - status is manual.
link currently points to /usr/local/bin/python3.9
/usr/local/bin/python3.9 - priority 10
Current `best' version is /usr/local/bin/python3.9.
[root@quickstart ~]# alternatives --set python /usr/local/bin/python3.9但是当我发布python --版本时,仍然是2.6
[root@quickstart ~]# python --version
**Python 2.6.6**
[root@quickstart ~]#编辑:即使按照这些步骤,$PATH在第一个参数中仍然有python2.6。可能是吗?$PATH在哪里配置?/etc/bashrc或~/.bashrc都没有它。
[root@quickstart ~]# whereis python
python: /usr/bin/python2.6 /usr/bin/python /usr/bin/python2.6-config /usr/lib/python2.6 /usr/lib64/python2.6 /usr/local/bin/python3.9-config /usr/local/bin/python3.9 /usr/local/lib/python3.9 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
[root@quickstart ~]#编辑2: /etc/替代品的python为3.9,但不是全局的。
[root@quickstart alternatives]# pwd
/etc/alternatives
[root@quickstart alternatives]# ./python --version
Python 3.9.10
[root@quickstart alternatives]# python --version
Python 2.6.6
[root@quickstart alternatives]#发布于 2022-02-10 19:04:58
在替代品中添加python2.6:
sudo alternatives --install /usr/bin/python python /usr/local/bin/python2.6 5然后将python3.9设为defaut:
sudo alternatives --config python或者用所需的python版本覆盖符号链接:
sudo ln -fs /usr/bin/python3.9 /usr/bin/pythonhttps://unix.stackexchange.com/questions/690064
复制相似问题