gpt4 book ai didi

python - 没有名为请求 PythonAnywhere 错误的模块

转载 作者:太空宇宙 更新时间:2023-11-04 08:04:39 24 4
gpt4 key购买 nike

我需要在我的代码中使用 urllib 模块,我这样导入它:

import urllib.request
import urllib.error

但 PythonAnywhere 返回以下错误:

> 没有名为 request 的模块

当我尝试时,看起来 urllib 库已成功导入:

python3 myscript.py

代替:

python myscript.py

但在这种情况下我得到另一个错误:

> 没有名为“pyvirtualdisplay”的模块

Pyvirtualdisplay 在我的代码中也需要,所以我不知道该怎么做。有人可以帮忙吗?

最佳答案

The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error ~ urllib2 - python docs

当你运行你的脚本时使用

python myscript.py

您的系统使用的是 python2,它没有 urllib.requesturllib.error 模块。使用 urllib2 库。

关于python - 没有名为请求 PythonAnywhere 错误的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33551425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com