close

How can I import urlparse in python-3?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How can I import urlparse in python-3 in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How can I import urlparse in python-3?

  1. How can I import urlparse in python-3?

    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

  2. I import urlparse in python-3

    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

Method 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

Method 2

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

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read