-1

我已经在已经安装了 python2.4 的 CentOS 机器上的 /opt/python2.7.1/ 下安装了 python,并将其配置为默认运行 python2.7。

但是,当我编写“easy_install”时,它会引发错误,例如

Traceback (most recent call last):
    File "/opt/python2.7.1/bin/easy_install", line 5, in ?
        from pkg_resources import load_entry_point
    File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2482, in ?
        for dist in working_set.resolve(
    File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
        raise DistributionNotFound(req)  # XXX put more info here
    pkg_resources.DistributionNotFound: setuptools==0.6c11

我认为easy_install/usr/bin/指向 python2.4 的链接下。我怎样才能运行/opt/python2.7.1/bin/easy_install默认值?

对于 $PATH:

/opt/python2.7.1/bin:/usr/devs/bin:/usr/local/bin:/bin:/usr/bin:/home/ops/bin

对于 $LD_LIBRARY_PATH:

/opt/python2.7.1/lib:

对于easy_install:

Traceback (most recent call last):
File "/opt/python2.7.1/bin/easy_install", line 5, in ?
    from pkg_resources import load_entry_point
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2482, in ?
    for dist in working_set.resolve(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==0.6c11
4

1 回答 1

2

您必须使用virtualenv才能使事情正常运行,并且在具有多个 Python 版本的系统中无需担心。

实际上,如果您运行多个 Python 应用程序,即使在具有单个 Python 版本的系统 q 中,它也是相当有帮助的。

Visrtualenv 不仅会为您设置所有适当的环境变量以使用一种 Python 或另一种 Python,因为它允许您使用单独的环境,您可以安全地“轻松安装”Python 2.4 模块而不会与 CentOS .rpm 冲突这些相同模块的包。

于 2012-10-04T12:05:10.370 回答