选择egg安装的Python版本或安装并行版本的site-package

发布于 2024-08-07 07:46:22 字数 722 浏览 8 评论 0原文

通过fink install,我在 Mac OS X 计算机上安装了以下 Python 版本:

  • python2.3
  • python2.4
  • python2。 5、
  • python2.6

此外,python 是我系统上 python2.6 的别名。

  1. 我想安装 egg< /a>,例如 easy_install networkx-0.36-py2.5.egg,我必须使用 python 2.5 而不是 2.6 版本。这可以在不更改 python 别名的情况下实现吗?

  2. 您能否告诉我,是否以及如何并行安装 networkx-0.36-py2.5networkx-1.0rc1-py2.6

  3. 如何以可用于不同 Python 版本的方式安装站点包?

Via fink install I put the following Python version on my Mac OS X computer:

  • python2.3,
  • python2.4,
  • python2.5,
  • python2.6.

Further, python is alias for python2.6 on my system.

  1. I want to install an egg, e.g. easy_install networkx-0.36-py2.5.egg, where I have to use python 2.5 instead of version 2.6. Is this possible without changing the python alias?

  2. Can you tell me, whether and how I can install networkx-0.36-py2.5 and networkx-1.0rc1-py2.6 in parallel?

  3. How can I install a site-package in a way, that it is available for different Python versions?

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

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

发布评论

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

评论(2

皇甫轩 2024-08-14 07:46:22

easy_installsetuptools 包的一部分。 Fink 具有适用于 python 2.5 和 python 2.6 的单独 setuptools 软件包:

fink install setuptools-py25 setuptools-py26

然后您可以下载并安装 networkx 到这两个版本:

/sw/bin/easy_install-2.5 networkx
/sw/bin/easy_install-2.6 networkx

如果您需要特定版本包装的:

/sw/bin/easy_install-2.5 networkx==0.36
/sw/bin/easy_install-2.6 networkx==0.36

easy_install is part of the setuptools package. Fink has separate setuptools packages for python 2.5 and python 2.6:

fink install setuptools-py25 setuptools-py26

You can then download and install networkx to both versions:

/sw/bin/easy_install-2.5 networkx
/sw/bin/easy_install-2.6 networkx

If you need a particular version of the package:

/sw/bin/easy_install-2.5 networkx==0.36
/sw/bin/easy_install-2.6 networkx==0.36
偏闹i 2024-08-14 07:46:22

编辑:阅读在阅读本文之前,Ned Deily 的回答


1.

在我的系统上,每个 python 版本都有不同的 easy_install 脚本:

  • /usr/bin/easy_install-2.5
  • /usr /bin/easy_install-2.6

2.6 版本的内容如下所示:

#!/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
import sys
sys.argv[0] = sys.argv[0].replace('-2.6', '')
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==0.6c9','console_scripts','easy_install'
__requires__ = 'setuptools==0.6c9'
import sys
from pkg_resources import load_entry_point

sys.exit(
   load_entry_point('setuptools==0.6c9', 'console_scripts', 'easy_install')()
)

现在,如果您的计算机上还没有这些脚本,您可以使用上述内容作为模板来创建它们。只需更改第一行,使其指向正确的 python 解释器。可能是这样的:

#!/sw/bin/python23

并更改第三行以匹配当前脚本名称;意思是,如果脚本名为 easy_install-2.3,那么它应该如下所示:

sys.argv[0] = sys.argv[0].replace('-2.3', '')

当然,如果您没有使用 setuptools 版本 0.6c9,那么您也必须更改它。


另一种方法是运行 easy_install 脚本作为正确 python 版本的参数。像这样:

$ python23 /some/path/easy_install networkx-0.36-py2.5.egg

2.

每个Python版本都有不同的site-lib,因此它们是相互独立的。您可以为不同的 python 版本安装不同的模块和版本

3.

您可以使环境变量 PYTHONPATH 指向一个公共目录,或者将一个公共目录添加到您的 sys.path 中。脚本。但请注意,某些模块仅适用于某些 python 版本,并且包含必须为每个 python 版本编译的 C 代码...

Edit: Read Ned Deily's answer before you read this one


1.

On my system I have different easy_install script for each python version:

  • /usr/bin/easy_install-2.5
  • /usr/bin/easy_install-2.6

The contents of the 2.6 version looks like this:

#!/System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
import sys
sys.argv[0] = sys.argv[0].replace('-2.6', '')
# EASY-INSTALL-ENTRY-SCRIPT: 'setuptools==0.6c9','console_scripts','easy_install'
__requires__ = 'setuptools==0.6c9'
import sys
from pkg_resources import load_entry_point

sys.exit(
   load_entry_point('setuptools==0.6c9', 'console_scripts', 'easy_install')()
)

Now, if you not already have those scripts on you machine, you could create those by using the above as template. Just change the first line so it points to the right python interpreter. Probably something like:

#!/sw/bin/python23

And change the third line to match the current script name; meaning, if the script is called easy_install-2.3, then it should look like this:

sys.argv[0] = sys.argv[0].replace('-2.3', '')

And of course if you are not using setuptools version 0.6c9 than you will have to change this, too.


An alternative is to run the easy_install script as an argument of the right python version. Like this:

$ python23 /some/path/easy_install networkx-0.36-py2.5.egg

2.

Each python version has a different site-lib, so they are independent from each other. You can install different modules and versions for different python versions

3.

You could make the env variable PYTHONPATH point to a common directory or add a common directory to sys.path in your scripts. But be aware that some modules work only with certain python versions and include C code that has to be compiled for each python version...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文