为什么“ pip install”会在setup.py中引发SyntaxError?

时间:2018-09-16 20:18:26

标签: python pip

我尝试通过pip安装python软件包,这会在setup.py中引发SyntaxError:

$ /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。

2 个答案:

答案 0 :(得分:1)

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

a = ['Fri, 19 Aug 2011 19:28:17 -0000',....., 'Wed, 05 Feb 2012 11:00:00 -0000']

答案 1 :(得分:0)

apt-get update
apt-get install python python-pip
python -m pip install --no-cache-dir setuptools==20.7.0
python -m pip install xxx