How can I import urlparse in python-3?
Solution 1
The urlparse in Python 2.7.11 was renamed to urllib.parse in Python 3.
So, if you have a code such from urlparse import urljoin
, I suggest you change it to from urllib.parse import urljoin
Solution 2
As noted in urlparse
's documentation:
Note The
urlparse
module is renamed tourllib.parse
in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.
I.e., just use urllib.parse
instead:
import urllib.parse
Mohamed Mahdi
This is Mohamed Mahdi's profile, and this is a bit of copy about me. I'm a data scientist, AI Engineer and tech content creator and strategist. That's not giving you a lot of detail, is it? So you can see more about my work experience on my profile.
Updated on July 08, 2022Comments
-
Mohamed Mahdi almost 2 years
I would like to use
urlparse
. But python3.4.1 is not finding the module.I do
import urlparse
, but it gives me this errorimportError: no 'module' named ulrparse