如何将 python 路径重置为 /usr/bin/python?

如何将 python 路径重置为 /usr/bin/python?

我按照某些说明安装软件包,结果安装了另一个版本的 python 并创建了符号链接(我不记得名字了)。现在,当我从终端点击 python 时,它指向/usr/local/python2.7/bin/python2.7。我需要将默认 python 重置为/usr/bin/python。怎么做?

$ which python
/usr/bin/python
$ whereis python
python: /usr/bin/python2.7-config /usr/bin/python2.7 /usr/bin/python /etc/python2.7 /etc/python /usr/lib/python2.7 /usr/bin/X11/python2.7-config /usr/bin/X11/python2.7 /usr/bin/X11/python /usr/local/bin/python2.7 /usr/local/lib/python2.7 /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
$ 
$ python
bash: /usr/local/python2.7/bin/python2.7: No such file or directory
$ 
$ /usr/bin/python
Python 2.7.3 (default, Dec 18 2014, 19:10:20) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

答案1

$ sudo rm /usr/bin/python
$ sudo ln -s /usr/bin/python2.7 /usr/bin/python

答案2

尝试sudo apt-get install --reinstall python-minimal

答案3

尝试$PATH在 .bashrc 中再次更新(即使它在 中定义$PATH)这样 PATH 的顺序将被间接改变,并且首先选择 /usr/bin/ 然后它才会转到 /usr/local/bin

PATH=/usr/bin:$PATH

相关内容