Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I import urlparse in python-3? [duplicate]

I would like to use urlparse. But python3.4.1 is not finding the module.

I do import urlparse, but it gives me this error

importError: no 'module' named ulrparse 
like image 937
Mohamed Mahdi Avatar asked Jan 03 '18 06:01

Mohamed Mahdi


2 Answers

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

like image 60
Abhijit Avatar answered Sep 21 '22 02:09

Abhijit


As noted in urlparse's documentation:

Note The urlparse module is renamed to urllib.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 
like image 32
Mureinik Avatar answered Sep 20 '22 02:09

Mureinik