python是安装在/usr/bin/下,正常的软链接指向/usr/bin/python.
ls py*
root@iZ9ni05fy7agndgpndc7gsZ:/usr/bin# ls py*
py3clean py3versions pyclean pydoc pydoc3 pygettext pygettext3 python python2.7 python2-config python3.5 python3m pyversions
py3compile pybuild pycompile pydoc2.7 pydoc3.5 pygettext2.7 pygettext3.5 python2 python2.7-config python3 python3.5m python-config
看到除了py2.7外,还有py3.5
whereis python
root@iZ9ni05fy7agndgpndc7gsZ:/usr/bin# whereis python
python: /usr/bin/python /usr/bin/python3.5 /usr/bin/python3.5m /usr/bin/python2.7 /usr/bin/python2.7-config /usr/lib/python3.5 /usr/lib/python2.7 /etc/python /etc/python3.5 /etc/python2.7 /usr/local/lib/python3.5 /usr/local/lib/python2.7 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
把3.5设置为优级级1,即可以了。
root@iZ9ni05fy7agndgpndc7gsZ:/usr/bin#
方法1:格式:
update-alternatives: --install needs <link> <name> <path> <priority>
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1
如果你是3.8或3.10版修改一下。
方法2:
另外,注意安装python版本的地址,每个人安装的地址可能有不同。
比如,新装了python3.8,
ln -s /usr/bin/python3.8 /usr/bin/python