Python 2.7:无法安装/查找任何依赖项

时间:2019-06-05 15:26:11

标签: python python-2.7 pip

我正在运行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

上面的脚本抱怨即使我已经使用pip安装了模块parse,也找不到它。我尝试使用的其他库也是如此。

这是为什么?

1 个答案:

答案 0 :(得分:3)

urllib.parse是python3,即您的脚本看起来像是针对python3的

python2中的

urlparse

因此使用python3运行它。现在您还是应该使用python3

作为旁注:安装的parse软件包用于其他用途-解析字符串