我读过这个 问题
- 我安装了 pip 并执行了
pip install requests
并得到
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local/lib/python2.7/dist-packages/requests-2.9.1-py2.7.egg
Cleaning up...
- 我启动了我的 python2 shell:
>>> from urllib.request import urlopen
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named request
为什么我仍然捕获这个异常?我做错了什么?
原文由 Rudziankoŭ 发布,翻译遵循 CC BY-SA 4.0 许可协议
您将名为
requests
的第三方模块与 Python 3 的内置urllib.request
了。您可以使用都使用 Python 2 和 3。但是,您可以使用
仅适用于 Python 3。