Linux 如何在 ubuntu 中将 python 2.6 更新到 python 2.7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9139826/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:23:03  来源:igfitidea点击:

How to update python 2.6 to python 2.7 in ubuntu

pythonlinux

提问by

I installed ubuntu 10.04 and it comes with python2.6. How can I upgrade it to 2.7?

我安装了 ubuntu 10.04,它带有 python2.6。如何将其升级到 2.7?

回答by Kracekumar

Download python 2.7.2and follow the step. Just remember use make installdont do make altinstall, this will not make python 2.7as default python interpreter.

下载python 2.7.2并按照步骤操作。请记住使用make installdont do make altinstall,这不会python 2.7成为默认的 python 解释器。

Edit: Don't replace or uninstall python 2.6 if it came with distro, this might lead to breaking packages.

编辑:如果 python 2.6 随发行版一起提供,请不要替换或卸载它,这可能会导致软件包损坏。

回答by starenka

You can also install python2.7 package. Then you can define python version with shebang (#!/usr/bin/env python2.7) or even use #update-alternatives --config pythonto make it default interpreter. But it can break a lot of system apps...

您也可以安装 python2.7 包。然后你可以使用 shebang ( #!/usr/bin/env python2.7)定义 python 版本,甚至可以使用#update-alternatives --config python它来使其成为默认解释器。但它可以破坏很多系统应用程序......

update: sometimes, there's no alternative to python, so you'll need to create those by hand. Something like update-alternatives --install /usr/bin/python python2.7 /usr/bin/python2.7 10

更新:有时,python 没有替代品,因此您需要手动创建它们。就像是update-alternatives --install /usr/bin/python python2.7 /usr/bin/python2.7 10

update2: nevertheless if you just need 2.7 for your project, I'd suggest using virtualenv: virtualenv -ppython2.7 myproject

update2:不过,如果您的项目只需要 2.7,我建议您使用 virtualenv: virtualenv -ppython2.7 myproject