我安装的Ubuntu 默认的python是2.7.5
python -V
我参考网上照到的文章,如果需要默认python为 python3
python命令默认是 python 3
sudo cp /usr/bin/python /usr/bin/python_bak #备份默认的python文件
sudo rm /usr/bin/python #移除
sudo ln -s /usr/bin/python3 /usr/bin/python #使用软链接,
python命令默认是 python 2
sudo cp /usr/bin/python /usr/bin/python_bak #备份默认的python文件
sudo rm /usr/bin/python #移除
sudo ln -s /usr/bin/python2 /usr/bin/python #使用软链接,
[email protected]:/usr/bin$ ls -l|grep python
-rwxr-xr-x 1 root root 1056 4月 16 2018 dh_python2
lrwxrwxrwx 1 root root 23 7月 10 00:51 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx 1 root root 23 8月 21 01:12 pdb3.6 -> ../lib/python3.6/pdb.py
lrwxrwxrwx 1 root root 31 10月 1 18:09 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx 1 root root 9 4月 16 2018 python -> python2.7
lrwxrwxrwx 1 root root 9 4月 16 2018 python2 -> python2.7
-rwxr-xr-x 1 root root 3633480 7月 10 00:51 python2.7
lrwxrwxrwx 1 root root 9 10月 1 18:09 python3 -> python3.6
-rwxr-xr-x 2 root root 4526456 8月 21 01:12 python3.6
-rwxr-xr-x 2 root root 4526456 8月 21 01:12 python3.6m
lrwxrwxrwx 1 root root 10 10月 1 18:09 python3m -> python3.6m
lrwxrwxrwx 1 root root 29 4月 16 2018 pyversions -> ../share/python/pyversions.py
References
原文地址:https://www.cnblogs.com/fsong/p/11616381.html
时间: 2024-11-13 12:01:36