Can't Fix Importerror: No Module Named Request Error
Solution 1:
It seems that you have two Python versions (3.7, 3.8) so when you install request
it may be in either of two places.
I installed and setup pyenv
and on top, virtualenvwrapper
for issues like this; it was a long run solution but it payed off.
https://realpython.com/intro-to-pyenv/
https://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html
Review your .bashrc
(or similar on Mac/Windows). You may have careful when changing PATH and other environment variables.
If it is an standalone app, it is ok to have your shebang #!/usr/bin/env python3
Where is urllib
This urllib library seems builtin so it may be an issue of the Python installation.
Please find if you have the particular file:
ls /home/USER/.pyenv/versions/3.7.0/lib/python3.7/urllib/ # On Linux with pyenv# For me, it lists "request.py" and others
On the Python command line (and my current environment), this is what I got:
>>> import urllib as ur
>>> ur.__path__
['/home/USER/.pyenv/versions/3.7.0/lib/python3.7/urllib']
>>> import urllib.request as rq
>>> dir(rq)
['AbstractBasicAuthHandler', 'AbstractDigestAuthHandler', 'AbstractHTTPHandler', ..., 'urlsplit', 'urlunparse', 'warnings']
Post a Comment for "Can't Fix Importerror: No Module Named Request Error"