Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import urllib.request and urllib.parse

I will be grateful for any help. I use Python 3.4.1 and I try to import urllib.request and urllib.parse. Without success. I always receive:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/x/Documents/PROGRAMING and MODELING/Phyton/find cure words/importowanie.py", line 1, in <module>
    import urllib.parse
  File "C:/Users/x/Documents/PROGRAMING and MODELING/Phyton/find cure words\urllib.py", line 1, in <module>
    import urllib.request
ImportError: No module named 'urllib.request'; 'urllib' is not a package

I guess the problem is with importing but I don't know how to go around it

like image 315
Legionista Avatar asked Jan 10 '23 10:01

Legionista


1 Answers

Without the actual code, I am guessing based on my past experience with such an error.

I presume you are trying to import urllib.parse in a file called importowanie.py in C:/Users/x/Documents/PROGRAMING and MODELING/Phyton/find cure words. When Python tries to import a module by the name urllib, it first checks in the same folder from where you are trying to import. In your case, it sees that there is a module called urllib in the same folder from where you are trying to import it. It sees inside that module instead of the "real" urllib. As it sees nothing called parse inside your urllib it raises an error. It is because of a file called urllib.py in C:/Users/x/Documents/PROGRAMING and MODELING/Phyton/find cure words.

So a solution would be to rename urllib in the above directory to something else and try again.

like image 81
Saimadhav Heblikar Avatar answered Jan 17 '23 05:01

Saimadhav Heblikar