Python urllib.request - 没有名为请求的模块

Python urllib.request - no module named request

我已经阅读了许多类似的帖子,但 none 解决了我的问题。当尝试导入请求时,我得到一个响应,说没有名为 request 的模块。

全新安装 Ubuntu 15.04 我已经安装了 pip3 我已经安装了请求

这是最新的输出:

binx@Binx:~/Python$ sudo pip3 install requests --upgrade

Downloading/unpacking requests from https://pypi.python.org/packages/2.7/r/requests/requests-2.7.0-py2.py3-none-any.whl#md5=564fb256f865a79f977e57b79d31659a Downloading requests-2.7.0-py2.py3-none-any.whl (470kB): 470kB downloaded Installing collected packages: requests Found existing installation: requests 2.2.1 Not uninstalling requests at /usr/lib/python3/dist-packages, owned by OS Successfully installed requests Cleaning up...

binx@Binx:~/Python$ python connect.py

Traceback (most recent call last): File "connect.py", line 7, in import urllib.request

ImportError: No module named request

binx@Binx:~/Python$

如果您能显示您的 connect.py 文件的代码,那将是最好的。

据我现在所见,我猜你是 运行 python 2.x 因为只有在 python3 中 urllib 被拆分为 urllib.request.在终端中输入 'python' 后找出 运行 的版本,然后尝试使用 'python3' 代替。

我还看到你是新来的,所以如果有人发布了正确答案,请不要忘记接受正确答案。