This question already has an answer here:
这个问题在这里已有答案:
- How to change the default version of python in a linux machine ?(not just symlink) [closed] 1 answer
如何在linux机器上更改python的默认版本?(不仅仅是符号链接)[关闭] 1回答
I've recently installed linux and got it working as a dual boot on my laptop. I have both python 2.7 and python 3.3 installed on my system. The problem is that when I run python
it runs the python 2.7 interpreter rather than python 3.3 as I would like it to. I can run the 3.3 interpreter with python3.3
but I would rather run the latest version with the shorter command, however I don't know how to change this. Any help regarding this would be most appreciated.
我最近安装了linux,并在笔记本电脑上将其作为双启动工具。我的系统上安装了python 2.7和python 3.3。问题是,当我运行python时,它运行python 2.7解释器而不是python 3.3,正如我所希望的那样。我可以使用python3.3运行3.3解释器,但我宁愿使用较短的命令运行最新版本,但我不知道如何更改它。任何有关这方面的帮助将非常感激。
1 个解决方案
#1
1
There are multiple ways to change what python
gets you, one of the safer ways to get python3.3
is to use an alias described here. You may want to alias python
to python3
as that should give you 3.3 now, and 3.4 when you upgrade in the future.
有多种方法可以改变python对你的影响,获得python3.3的一种更安全的方法是使用这里描述的别名。您可能希望将python别名为python3,因为它现在应该给你3.3,以及将来升级时的3.4。
If you want to update the default systemwide, you can try:
如果要更新系统范围的默认值,可以尝试:
sudo update-alternatives --config python
as mentioned elsewhere.
如其他地方所述。
Edit: Please note that various operating systems integrate a specific version of python and various updates and packages may break if python
doesn't work exactly as expected. There are, of course, many ways to handle python versions (use of python3
on the command line, virtualenv, pythonbrew, to name some of them).
编辑:请注意,各种操作系统集成了特定版本的python,如果python不能完全按预期工作,各种更新和包可能会中断。当然,有许多方法可以处理python版本(在命令行上使用python3,virtualenv,pythonbrew,以命名其中一些)。
#1
1
There are multiple ways to change what python
gets you, one of the safer ways to get python3.3
is to use an alias described here. You may want to alias python
to python3
as that should give you 3.3 now, and 3.4 when you upgrade in the future.
有多种方法可以改变python对你的影响,获得python3.3的一种更安全的方法是使用这里描述的别名。您可能希望将python别名为python3,因为它现在应该给你3.3,以及将来升级时的3.4。
If you want to update the default systemwide, you can try:
如果要更新系统范围的默认值,可以尝试:
sudo update-alternatives --config python
as mentioned elsewhere.
如其他地方所述。
Edit: Please note that various operating systems integrate a specific version of python and various updates and packages may break if python
doesn't work exactly as expected. There are, of course, many ways to handle python versions (use of python3
on the command line, virtualenv, pythonbrew, to name some of them).
编辑:请注意,各种操作系统集成了特定版本的python,如果python不能完全按预期工作,各种更新和包可能会中断。当然,有许多方法可以处理python版本(在命令行上使用python3,virtualenv,pythonbrew,以命名其中一些)。