【问题标题】:running pip install from python 2.7.5从 python 2.7.5 运行 pip install
【发布时间】:2013-09-10 06:04:56
【问题描述】:

我有一个 CentOS 服务器 (5.6),上面有 Python 2.4.3。我在/opt 中安装了另一个Python (2.7.5) 本地安装,并创建了如下/usr/local/bin/python2.7/usr/local/python2.7 的软链接。我想使用pip 安装 python-requests。使用命令pip install requests 安装时,出现以下错误:

root ~/ff_test_ff # pip install requests
Unpacking ./requests
  Running setup.py egg_info for package from file:///root/ff_test_ff/requests
    Traceback (most recent call last):
      File "<string>", line 14, in ?
      File "/tmp/pip-MM685m-build/setup.py", line 6, in ?
        import requests
      File "requests/__init__.py", line 58
        from . import utils
             ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in ?

  File "/tmp/pip-MM685m-build/setup.py", line 6, in ?

    import requests

  File "requests/__init__.py", line 58

    from . import utils

         ^

SyntaxError: invalid syntax

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /root/.pip/pip.log

我假设它仍在尝试使用 Python 2.4。我checked here 表示不支持 2.4。那么如何运行pip install 命令但使用python2.7呢?

【问题讨论】:

    标签: python python-2.7 pip


    【解决方案1】:

    您可能应该(重新)为新的 Python 版本显式安装新版本的 pip。 pip installation instructions page 上面写着

    pip 适用于 CPython 版本 2.6、2.7、3.1、3.2、3.3 以及 pypy。

    安装时,请务必使用较新版本的 Python 而不是旧版本。

    【讨论】:

      【解决方案2】:

      你需要设置PYTHONPATH/PYTHONHOMElike here

      你也可以尝试安装virtualenv

      【讨论】:

        猜你喜欢
        • 2020-01-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多