python - 为什么 "pip install"在 setup.py 中引发语法错误?

标签 python pip

我尝试通过 pip 安装 python 包,这会在 setup.py 中引发语法错误:

$ /usr/bin/pip install dash --user
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting dash
  Using cached https://files.pythonhosted.org/packages/ad/94/c591c1ff695c32e7fc5138525f3a792d289160008f1a7f517860cc744a85/dash-0.26.5.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-ysGuJO/dash/setup.py", line 5, in <module>
        exec(open('dash/version.py').read(), main_ns)  # pylint: disable=exec-used
      File "<string>", line 1
        __version__ = '0.26.5'
                              ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ysGuJO/dash/
You are using pip version 7.1.0, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

我在这里做错了什么?我想这与太旧的 python 版本有关:

$ python --version
Python 2.6.6

因为响应类似于 this, more specific question on stackoverflow

pip install urllib3 

工作正常,只需要 >= Python 2.6。

最佳答案

这是一个问题,因为 python 版本较旧。你可能需要升级你的Python。升级后,您将不会遇到任何问题。以下是升级步骤。在您的终端中写下步骤。

    # refreshing the repositories
    sudo apt update
    # its wise to keep the system up to date!
    # you can skip the following line if you not
    # want to update all your software
    sudo apt upgrade
    # installing python 2.7 and pip for it
    sudo apt install python2.7 python-pip
    # installing python-pip for 3.6
    sudo apt install python3-pip

关于python - 为什么 "pip install"在 setup.py 中引发语法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52358053/

相关文章:

python - Django 使用相关实体字段序列化查询集

python - 如何使用 python pillow 创建圆形缩略图并在背景图像上重叠

python - 在 Windows 7 x64 中的 PyPy3.5 v5.10 上使用 ensurepip 进行 pip 安装

Python:在套接字监听连接时显示消息 'Waiting for player...'

python - 如何绘制任意一点抛物线的斜率(切线)?

python-3.x - 有没有办法为Windows安装cython-bbox?

python - 如何在 Ubuntu 中安装指向自定义安装 Python3 的 Pip3?

未使用 pip 在 vi​​rtualenv 中安装 Python 包

python - 在 XCode 4 中运行 PyObjC 模板时发生泄漏

python - Gohlke 的 numpy + mkl 安装 - 更改 Windows 上的 MKL 安装目录