No module named 'urlparse' but I'm not using urlparse No module named 'urlparse' but I'm not using urlparse flask flask

No module named 'urlparse' but I'm not using urlparse


For python3 I have used

from urllib.parse import urlparse

instead of from urlparse import parse_qsl, urlparse and it works

recommended doc : https://docs.python.org/3/library/urllib.parse.html


The flask_oauth library doesn't support Python3 - you'll see from the traceback:

Traceback (most recent call last):  File "app.py", line 3, in <module>    from flask_oauth import OAuth  File "/Users/matthealy/virtualenvs/test/lib/python3.6/site-packages/flask_oauth.py", line 13, in <module>    from urlparse import urljoinModuleNotFoundError: No module named 'urlparse'

The urlparse module's behaviour was changed in Python 3:

https://docs.python.org/2/library/urlparse.html

The urlparse module is renamed to urllib.parse in Python 3.

This has been raised with the package maintainers on Github. The source on Github looks to be fixed, but the fixed version has not been pushed to pypi.

The solution suggested on Github is to install directly from source instead of pypi:

pip install git+https://github.com/mitsuhiko/flask-oauth


In your stack trace, find which file propagates the ModuleNotFoundError. If it's from one of your own source files, refactor your code, so urlparse is imported like:

urllib.parse import urlparse

Otherwise, find the module to which that file belongs to. Then upgrade that module.

pip install --upgrade [module-name]