I need to use urllib module in my code and I import it like this:
import urllib.request
import urllib.error
but PythonAnywhere returns the following error:
> No module named request
It looks like the urllib library is imported successfully when I try:
python3 myscript.py
instead of:
python myscript.py
But in this case I get another error:
> No module named 'pyvirtualdisplay'
Pyvirtualdisplay is also needed in my code, so I dont know what to do. Can someone help ?
The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error ~ urllib2 - python docs
When you run your script using
python myscript.py
Your system is using python2 which doesn't have the urllib.request
and urllib.error
modules. Use the urllib2
library.