如何在Linux机器中更改python的默认版本?(不仅仅是symlink) [英] How to change the default version of python in a linux machine ?(not just symlink)

查看:168
本文介绍了如何在Linux机器中更改python的默认版本?(不仅仅是symlink)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于各种原因和用途,我在ubuntu(精确)中安装了多个python版本。我有python 2.7和python 2.6。我需要将python 2.6设置为默认值,而不是python 2.7。我更新了python symlink以指向python2.6。那只会让我直接使用python2.6进行命令行访问。但是当我从aptitude安装一些软件包时,它会直接与python2.7兼容,因为在OS中的某个地方,它会将其视为默认值。我应该如何更改?

I have multiple versions of python installed in ubuntu (precise) for various reasons and uses. I have python 2.7 and python 2.6. I need to make python 2.6 the default and not python 2.7. I updated python symlink to point to python2.6. That will only give me commandline access straight to python2.6. but when I install some package from aptitude, it goes straight to python2.7 compatible stuff because somewhere in the OS, its sees that as the default. How should I change this ?

P.S:我知道从软件包的源代码安装的解决方法。但是要始终获得源代码并不容易,而且并非都是慷慨的。

P.S : I know the workaround of installing from package's source code. But its not easy to get the source code always and not all are generous.

推荐答案

在Ubuntu和其他Debian衍生的发行版中,定义哪个Python版本在系统范围内运行的正确方法是使用 sudo update-alternatives --config python 。另请参见 http://www.stylesen.org/python_27_debian_squeeze_60

On Ubuntu and other Debian-derived distributions, the proper way to define which Python version to run system-wide is with sudo update-alternatives --config python. See also http://www.stylesen.org/python_27_debian_squeeze_60

这篇关于如何在Linux机器中更改python的默认版本?(不仅仅是symlink)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆