如何在 Ubuntu 11.10 中使用 Python 2.6?

发布于 2024-12-16 10:57:29 字数 389 浏览 2 评论 0原文

Ubuntu 11.10 上的默认 Python 版本是 2.7,但我正在寻找 2.6。如何将其设置为默认值以及可执行文件位于何处?

我输入 which python2.6 但它什么也没返回,但我在 /usr/lib/python2.6 下确实有一个 python2.6 文件夹。但它看起来不像python2.7,它位于相同的路径/usr/lib/。在python2.6中,有两个文件夹:dist-packageslib-dynload

实际上我正在配置 PyDev,它要求我指定 python2.6 可执行文件的位置。只需使用自动配置即可轻松找到 python2.7 可执行文件,因为它是默认的。

The default version of Python on Ubuntu 11.10 is 2.7, but I'm looking for 2.6. How do I make it default and where is the executable located?

I type which python2.6 but it returns nothing, yet I did have a python2.6 folder under /usr/lib/python2.6. But it doesn't look like the python2.7 which is at the same path /usr/lib/. Inside the python2.6, there are two folders: dist-packages and lib-dynload.

Actually I am configuring PyDev, and it requires me to specify where the python2.6 executable is. The python2.7 executable has been easily located by just using auto configuration as it is the default.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如果没结果 2024-12-23 10:57:30

您可以安装包 python2.6 (apt-get install python2.6)。此时,Python 的默认版本仍为 2.7。您可以通过以下方式更改此设置

ln -s /usr/bin/python2.6 /usr/bin/python

:请注意,这很有可能会导致您的系统出现问题。一些脚本假定 Python 的默认版本是 2.7,并且在不同版本下运行时可能会中断。如果您有一个明确需要 Python 2.6 的脚本,您可以在脚本的开头添加一个 shebang 来指定版本

#!/usr/bin/python2.6

You can install the package python2.6 (apt-get install python2.6). At this point, the default version of Python will still be 2.7. You can change this via

ln -s /usr/bin/python2.6 /usr/bin/python

Note that there's a decent chance this could cause problems with your system. Several scripts assume the default version of Python is 2.7 and may break when run under a different version. If you have a script that explicitly requires Python 2.6, you can add a shebang at the beginning of your script to specify the version

#!/usr/bin/python2.6
榕城若虚 2024-12-23 10:57:30

在许多系统上,Python 的一个版本是默认的。其余的按名称和版本号调用:

~ $ python --version
Python 2.7.2
~ $ python2.6 --version
Python 2.6.7

根据 发行说明,这些应该是在梦魇中可用。

您的其他问题:

  • 它在哪里?运行 $ which python2.6 来找出答案。
  • 如何将其设置为默认值?最安全的方法是使用别名,这样更改只有您自己可见。否则,如果将 /usr/bin/python 重新指向意外的 Python 版本,则可能会破坏依赖 Python2.7 的操作系统脚本。与其更改默认值,不如只调用您需要的特定 Python 版本。

On many systems, one version of python is the default. The rest get called by their name and version number:

~ $ python --version
Python 2.7.2
~ $ python2.6 --version
Python 2.6.7

Per the release notes, these should be available in Oneiric.

Your other questions:

  • Where is it? Run $ which python2.6 to find out.
  • How to make it the default? The safest way is to use alias so that change will be only visible to you. Otherwise, if you repoint /usr/bin/python to an unexpected version of Python, you will may break the OS scripts that rely on Python2.7. Rather than changing the default, it is better to just call the specific version of Python you need.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文