How to fix python import requests not found

10 May,2022 by Rambler

Question : I'm trying to execute a Python script but getting an Import Requests module error . How can I fix ?

Answer: The Python Requests module does not come with the default Python installation therefore you will need to download and install . You can do that via the pip command. Here is an example of how to use pip and install the python Requests module . pip is the Python package installer which allows you to install Python packages . If you  haven't added pip to the %PATH% then you'll need to locate it on the path where you installed Python 

python -m pip install requests

 

You may find when executing this command line - that you get a warning\error message similar to : SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate 

As a temporary workaround you can use the --trusted host method to overcome the issue . 

pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org requests

You should now see a different response on the screen , similar to : 

 

Collecting requests
Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
|████████████████████████████████| 63 kB 1.5 MB/s
Collecting certifi>=2017.4.17
Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
|████████████████████████████████| 149 kB 1.1 MB/s
Collecting idna<4,>=2.5
Downloading idna-3.3-py3-none-any.whl (61 kB)
|████████████████████████████████| 61 kB 990 kB/s
Collecting urllib3<1.27,>=1.21.1
Downloading urllib3-1.26.9-py2.py3-none-any.whl (138 kB)
|████████████████████████████████| 138 kB 1.3 MB/s
Collecting charset-normalizer~=2.0.0
Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)


Author: Rambler (http://www.dba-ninja.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How to fix python import requests not found


dba-ninja.com