尝试使用pip将Python 2.7.0升级到Python 2.7.3:SyntaxError; python2和python3之间有困惑吗?

时间:2013-01-25 17:16:14

标签: python pip

我在/local/gerrit/python2.7的virtualenv中安装了Python 2.7.0。我想将其升级到Python 2.7.3。我正在尝试使用pip,但不知何故,它似​​乎在python2和python3之间混淆:

$ pip install --upgrade 'python>=2.7,<2.7.99'
Downloading/unpacking python>=2.7,<2.7.99 from http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
  Running setup.py egg_info for package python
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/local/gerrit/python2.7/build/python/setup.py", line 1804
        exec(f.read(), globals(), fficonfig)
    SyntaxError: unqualified exec is not allowed in function 'configure_ctypes' it contains a nested function with free variables
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/local/gerrit/python2.7/build/python/setup.py", line 1804

    exec(f.read(), globals(), fficonfig)

SyntaxError: unqualified exec is not allowed in function 'configure_ctypes' it contains a nested function with free variables

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /local/gerrit/python2.7/build/python
Storing complete log in /storage4/home/gerrit/.pip/pip.log

看起来/local/gerrit/python2.7/build/python/setup.py实际上有一个python3语法,而且有些东西搞砸了。我的诊断是否正确?如何以不需要重新安装Python及其所有库的方式清理它?

2 个答案:

答案 0 :(得分:1)

您可能需要使用pythonz之类的东西来管理同一台机器上的多个python安装。

然后当你使用像virtualenv之类的东西时,你会想要将它们指向你安装的二进制文件,你将拥有一个工作的virtualenv与python的特定副本

virtualenv -p /path/to/python

答案 1 :(得分:0)

另一个选项是pyenv,是pythonz的替代品。它的优点是不依赖于Python本身。