No module named urllib3

I wrote a script to call the API and successfully completed it last week. This week it will not work. I am returning the following error message:

Traceback (most recent call last): File "user_audit.py", line 2, in <module> import requests File "c:\Python27\lib\site-packages\requests\__init__.py", line 60, in <module> from .packages.urllib3.exceptions import DependencyWarning File "c:\Python27\lib\site-packages\requests\packages\__init__.py", line 29, in <module> import urllib3 ImportError: No module named urllib3 

I confirmed that the packages were updated, tried to uninstall and reinstall it, but so far nothing has worked. Can anyone help?

ADDITION

I installed urllib3 as suggested by @MSHossain, but then received another error message. The new post referred to another file that I wrote that created the compiled Python file. Another file used smptlib to try and send an email. I do not understand how this will happen, but I deleted another file and my script worked without problems. I accepted the answer below as I was able to install install urllib3, but it had to be included in the request module.

+11
source share
5 answers

either urllib3 is not imported or not installed.

for import, write import urllib3 at the top of the file for installation in the terminal, write pip install urllib3 . You cannot activate the environment variable correctly. To activate an environment variable, write the source env / bin / activate to the terminal. here env is the name of the environment variable.

+8
source

install the environment by writing the source env / bin / activate , if env is not found, write virtualenv env , then source env / bin / activate , and then check pip freeze if urllib3 is not found there then reinstall urllib3, hope this helps.

+1
source

A few minutes ago I ran into the same problem. And this is because I used a virtual environment. I believe that because of the venv directory, the installed pip might stop working.

Fortunately, I have a setting uploaded to my directory. I started the setup and chose the recovery option, and now everything works fine.

0
source

For me in PyCharm I had to put import urllib3 at the beginning of the file, as mentioned earlier, then PyCharm made it possible to import. Even after installing with pip

0
source
 pip install urllib3 

The reason it broke is because I installed an incompatible version of urllib3 as the urllib3 time dependency. You will see such conflicts when you restart the installation.

0
source

Source: https://habr.com/ru/post/1265137/


All Articles