本文介绍了python2.4和python2.7的easy_install冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have installed python under /opt/python2.7.1/ on CentOS machine which has already python2.4 and configure it to run python2.7 default.

但是,当我编写easy_install"时,它会引发类似

However, when I write 'easy_install' it raises error like

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

我认为 /usr/bin/ 下的 easy_install 链接到 python2.4.如何默认运行 /opt/python2.7.1/bin/easy_install?

I think easy_install under /usr/bin/ links to python2.4. How can I run /opt/python2.7.1/bin/easy_install default?

对于 $PATH:

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

对于 $LD_LIBRARY_PATH:

For $LD_LIBRARY_PATH:

/opt/python2.7.1/lib:

对于easy_install:

For 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

推荐答案

你必须使用 virtualenv 使事情正常工作,并且在具有多个 Python 版本的系统中不用担心.

You have to make use of virtualenv to get things working properly, and without worries in systems with more than one Python version.

实际上,如果您运行多个 Python 应用程序,即使在系统 q 中使用单个 Python 版本也很有帮助.

Actually, it is quite a help even in system qwith a single Python version, if you have muliple Python apps running.

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

Visrtualenv will not only take care of setting up all the appropriate environment variables for you to use one Python or another, as it will allow you to use use a separate environment where you can safely "easy_install" Python 2.4 modules without conflicting with CentOS .rpm packages of those same modules.

这篇关于python2.4和python2.7的easy_install冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 09:30