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
How to update python 2.6 to python 2.7 in ubuntu
提问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 install
dont do make altinstall
, this will not make python 2.7
as default python interpreter.
下载python 2.7.2并按照步骤操作。请记住使用make install
dont 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 python
to 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