【发布时间】:2019-10-21 03:28:02
【问题描述】:
我正在运行 Python 2.7.10,即使使用 pip 成功安装它们,我似乎也无法满足任何依赖项:
>python --version
Python 2.7.10
>sudo -H pip install parse
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: parse in /Library/Python/2.7/site-packages (1.12.0)
>python myScript.py
Traceback (most recent call last):
File "myScript.py", line 3, in <module>
from urllib.parse import urlparse
ImportError: No module named parse
myScript.py 的第 3 行如下所示:
from urllib.parse import urlparse
我的脚本上方抱怨模块 parse 无法找到,即使我已经使用 pip 安装了它。我也尝试使用的其他库也是如此。
这是为什么?
【问题讨论】:
-
你真的不应该使用 sudo (或者将库安装到系统的 Python 2 中)。使用
pyenv和/或获取 Python3
标签: python python-2.7 pip