“正道"在 archlinux 上管理多个版本的 Python [英] "Proper way" to manage multiple versions of Python on archlinux

查看:32
本文介绍了“正道"在 archlinux 上管理多个版本的 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我读过这个 - https://wiki.archlinux.org/index.php/蟒蛇

从这个 wiki 可以清楚地看出,我可以通过

And it is clear from this wiki that I can install Python 2.7.2 via

pacman -S python2

我为python2创建一个符号链接是否合理

Is it reasonable for me to create a symlink to python2

ln -s python2 /usr/bin/python

如果我没有预见到自己很快就会切换到 python 3.0?或者有没有更好的方法来管理多个 python 版本,比如我通常在 debian 系统 (update-alternatives --config python) 或 mac os x 系统 (python select) 上使用的方法?

if I don't forsee myself switching to python 3.0 any time soon? Or is there a better way of managing multiple python versions like what I usually use on a debian system (update-alternatives --config python) or on a mac os x system (python select)?

澄清:

  • 我想知道的是 - 在 archlinux 系统上管理各种 Python 版本的最佳实践"是什么?
  • 我是 archlinux 的新手,但熟悉 ubuntu、debian 和 mac os x

推荐答案

大多数 unices 已经有一个/usr/bin/python.覆盖它是一个坏主意,因为这是系统中所有包使用的 Python 版本,更改该版本可能会破坏它们.安装 Python 2.7 包时,可执行文件应安装为/usr/bin/python2.7(如果不是,我会声称 Archlinux 已损坏),当您想运行 Python 2.7 时最好使用它.

Most unices already have a /usr/bin/python. Overwriting that one is a bad idea, as this is the Python version used by all packages in the system, and changing that one may break them. When installing the Python 2.7 package the executable should be installed as /usr/bin/python2.7 (if not I would claim Archlinux is broken) and it's better to use that when you want to run Python 2.7.

Archlinux 有点特殊,因为它会为 Python 3 使用/usr/bin/python,尽管 Python 3 的默认可执行文件名称是/usr/bin/python3.这令人困惑并且可以被视为一个错误,但这确实意味着您不能将那个符号链接用于 Python 2,因为如果您这样做,任何其他使用 Python 3 的 Archlinux 脚本几乎肯定会中断.

Archlinux is a bit special, since it will use /usr/bin/python for Python 3, despite the default executable name for Python 3 being /usr/bin/python3. This is confusing and can be seen as a bug, but it does mean you can't use that symlink for Python 2, as any other Archlinux script that uses Python 3 will almost certainly break if you do.

所以在其他 Unices 上,将/usr/bin/python 符号链接到 Python 2.7 是一个坏主意,在 Archlinux 上这是一个糟糕的主意.相反,只需安装您需要的所有版本并使用/usr/bin/pythonX.X 调用它们.

So where on other Unices, symlinking /usr/bin/python to Python 2.7 is a bad idea, on Archlinux it is a terrible idea. Instead just install all version you need and call them with /usr/bin/pythonX.X.

这篇关于“正道"在 archlinux 上管理多个版本的 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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