python - 为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.
解决方案
您的 Python 2.7 安装似乎被扭曲了:模块collections
包含带有f''
-string 的代码,该代码仅适用于 Python 3。
我的建议是重新安装 Python 2.7。
推荐阅读
- python-3.x - 在 tkinter 帧之间移动
- python - 如何找到具有最大总和和大小的非相交子集的最小数量
- python - 尝试使用 pip 安装软件包但收到此错误“文件名、目录名或卷标语法不正确”
- python - 使用 Pandas Dataframe 绘制条形图
- python - 在卫星地图上绘制数据
- python - 通过 distinctDay 查找值在数据集 python 中出现的天数
- facebook - 如何确认指定用户是否使用图形 api 在 Facebook 中关注我的页面?
- animation - 同一对象上不同变换动画的 SVG 链
- react-native - 安全 api 端点的图像 getSize(使用授权)
- javascript - 如何将标记的javascript动态插入到html中