Changing default python to another version

2019-02-07 11:04发布

Currently when I use "python" command, it points to python2.6. I have installed python3.1 and I want the "python" command point to python3.1. How it is possible?

mahmood@mpc:~$ which python 
/usr/bin/python
mahmood@mpc:~$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 2010-11-24 16:14 /usr/bin/python -> python2.6
mahmood@mpc:~$ uname -a
Linux orca 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC 2010 x86_64 GNU/Linux

7条回答
手持菜刀,她持情操
2楼-- · 2019-02-07 11:33

You really don't want to change what python points to, because some programs might expect Python 2, and break.

The solution is to use virtualenv: create an isolated Python 3 environment (with the -p python3 option), activate it, and you're good to go.

查看更多
登录 后发表回答