Linux上两个版本的python。如何使2.7成为默认

Linux上两个版本的python。如何使2.7成为默认

我在linuxbox上有两个版本的python:


$python

Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) 

[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> 



$ /usr/local/bin/python2.7

Python 2.7.3 (default, Oct  8 2013, 15:53:09) 

[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> 


$ which python

/usr/bin/python

$ ls -al /usr/bin/python

-rwxr-xr-x. 2 root root 4864 Jul 10 22:49 /usr/bin/python

如何使2.7成为默认版本,所以当我键入python这让我进了2.7?


芜湖不芜
浏览 928回答 3
3回答

陪伴而非守候

加/usr/local/bin敬你的PATH环境变量,在列表中比/usr/bin.通常,这是在shell的RC文件中完成的,例如,对于bash,您可以将其放入.bashrc:export PATH="/usr/local/bin:$PATH"这将导致您的shell首先查找python在……里面/usr/local/bin,在它和那个在一起之前/usr/bin.(当然,这意味着你也需要/usr/local/bin/python指向python2.7-如果还没有,你就需要把它连接起来。)
打开App,查看更多内容
随时随地看视频慕课网APP