hsgggs
hsgggs

Reputation: 1

How can I install parse for python3 if I get importError?

So I'm working in Linux and I need to install parse for python3 but always get the same error: ImportError: No module named parse. I tried it:

  1. from urllib.parse import urlparse
  2. from parser import *
  3. try: from urllib.parse import urlparse except ImportError: from urlparse import urlparse (but as I know its only for python2, I work on python3). Also tried to do this pip install parse but had no result. Before it I had the next error “NameError: global name 'parse' is not defined”. Please can you help me, what should I do? I found that some people have the same problem but their resolutions dont help me

Upvotes: 0

Views: 523

Answers (1)

S.B
S.B

Reputation: 16496

urllib is in standard library, no need to install. It works ok for me in python 3.x. Probably you have named your script(the .py file you are running) to urllib. This is a common mistake, rename it to something else then it works.

It could happen even if you have a python file named urllib in your directory... because when you run your script, python will automatically add it's directory to sys.path(where python searched for modules/packages). So it gets reached sooner than the original urllib which is in the standard library.

Search that file in your directory and delete it.

Upvotes: 1

Related Questions