python - 尝试使用 pip : SyntaxError; confused between python2 and python3? 将 Python 2.7.0 升级到 Python 2.7.3

标签 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 及其所有库的方式清理它?

最佳答案

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

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

virtualenv -p/path/to/python

关于python - 尝试使用 pip : SyntaxError; confused between python2 and python3? 将 Python 2.7.0 升级到 Python 2.7.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14526971/

相关文章:

python-2.7 - 在 Jython 2.7.0 上安装 networkx 1.9.1

python - Airflow 安装成功,但无法运行

python - 是否有相当于 Octave 命令 `format bit` 的 python?

python - 如何在 Python 3.5 中键入提示属性?

android - 通过 Python 从 Android 获取设备/型号信息

python - pip install mysql-python错误

python - 为什么 pip 会卸载所需的包?

python - Google App Engine (Python) 中的电子商务产品类别

python - PyArg_ParseTuple 和回调函数指针

python - 成功安装flask,仍然出现导入错误