将默认python更改为另一个版本 [英] Changing default python to another version
问题描述
当前,当我使用"python"命令时,它指向python2.6.我已经安装了python3.1,并且希望"python"命令指向python3.1.怎么可能?
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
推荐答案
由于您使用的是Linux,并且如果您只想键入"python"而不是"python3"来运行Python程序,那么一个解决方案就是定义Shell配置文件中的别名(.bashrc等).对于Bourne贝壳,应该像
Since you have Linux, and if you want to simply type "python" instead of "python3" in order to run Python programs, a solution is simply to define an alias in you shell configuration file (.bashrc, etc.). For Bourne shells, it should be something like
alias python=python3
(或您的Python 3名称是什么).
(or whatever your Python 3 name is).
这样,您不必更改系统上的任何内容,因此此解决方案应该是无害的,并且不会破坏系统.
This way, you do not have to change anything on your system, so this solution should quite innocuous and it should not break your system.
这篇关于将默认python更改为另一个版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!