Acording to the docs:
Note The urllib2 module has been split across several modules in Python 3 named
urllib.request
andurllib.error
. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.
So it appears that it is impossible to do what you want but you can use appropriate python3 functions from urllib.request
.