pip install *有“语法错误”

时间:2016-04-22 17:29:53

标签: python pip

A有一个问题,尝试从pip安装模块,如:

Install packages failed: Error occurred when installing package lxml. 

The following command was executed:

packaging_tool.py install --build-dir C:\Users\User\AppData\Local\Temp\pycharm-packaging2629877941665473195.tmp lxml

The error output of the command:

C:\Python32\lib\site-packages\pip\_vendor\pkg_resources\__init__.py:87: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
  warnings.warn(msg)
Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 3.1\helpers\packaging_tool.py", line 125, in main
    retcode = do_install(pkgs)
  File "C:\Program Files (x86)\JetBrains\PyCharm 3.1\helpers\packaging_tool.py", line 56, in do_install
    import pip
  File "C:\Python32\lib\site-packages\pip\__init__.py", line 16, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "C:\Python32\lib\site-packages\pip\vcs\mercurial.py", line 9, in <module>
    from pip.download import path_to_url
  File "C:\Python32\lib\site-packages\pip\download.py", line 36, in <module>
    from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
  File "C:\Python32\lib\site-packages\pip\utils\ui.py", line 15, in <module>
    from pip._vendor.progress.bar import Bar, IncrementalBar
  File "C:\Python32\lib\site-packages\pip\_vendor\progress\bar.py", line 48
    empty_fill = u'\u2219'
                    ^
SyntaxError: invalid syntax

如何解决这个问题?我无法安装任何模块或回滚点。

Python 3.2 Pip 8.1.1

1 个答案:

答案 0 :(得分:3)

您需要升级Python。 Python 3.2不支持使用u"..."语法的Unicode字符串文字(因为所有字符串文字都是Python 3.x中的Unicode,因此不再需要这些文字)。这就是您收到错误的原因。

在Python 3.3中,恢复了这个功能,以便更容易编写在Python 2.x或3.x上运行的代码,显然PIP正在利用这一点。

确实,PIP 8.1.1 mentions的文档需要Python 3.3或更高版本。