首页 > 解决方案 > 为python 2.7 windows 10安装pip命令时出现属性错误

问题描述

我正在尝试使用以下命令安装 pip:

$python get-pip.py

但是,得到以下错误。我尝试了其他用户建议的有关属性错误的解决方案,但没有任何效果。

Traceback (most recent call last):
  File "get-pip.py", line 25, in <module>
    import shutil
  File "C:\Python27\lib\shutil.py", line 12, in <module>
    import collections
  File "C:\Python27\lib\collections\__init__.py", line 55
    raise AttributeError(f'module {__name__!r} has no attribute {name!r}')

我安装了正确版本的 python 并将其添加到 PATH 中。当我python在控制台上输入时,我得到以下输出:

Python 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:37:19) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

标签: pythonpip

解决方案


您的 Python 2.7 安装似乎被扭曲了:模块collections包含带有f''-string 的代码,该代码仅适用于 Python 3。

我的建议是重新安装 Python 2.7。


推荐阅读