简体   繁体   中英

Python Requests module no longer works

The module used to work but calling it now throws the following error:

Traceback (most recent call last):
File "C:\\Local_PythonScripts\\trial.py", line 2, in
import requests
File "C:\\Python36\\lib\\site-packages\\requests__init__.py", line 97, in

from . import utils
File "C:\\Python36\\lib\\site-packages\\requests\\utils.py", line 24, in
from . import certs
File "C:\\Python36\\lib\\site-packages\\requests\\certs.py", line 15, in
from certifi import where
ModuleNotFoundError: No module named 'certifi'

I think I trashed this myself by running some code on PIP in the command console that I copied off Stack Overflow while trying to resolve an error that was saying that a web pages certificate couldn't be verified. The code I ran added something and removed something else and I've tried to find it again so I could show it here but to no avail.

I've tried deleting and reloading "requests" but it won't load the 'certifi' module, the relevant text I get after running PIP in the command window is:

Could not fetch URL https://pypi.org/simple/certifi/ : There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443):
Max retries exceeded with url: /simple/certifi/ (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),)) - skipping
Could not find a version that satisfies the requirement certifi>=2017.4.17
(from requests) (from versions: )
No matching distribution found for certifi>=2017.4.17 (from requests)

First of all you can install pip install certifi then upgrade your pip using this command python -m pip install --upgrade pip then try to install pip install requests . It was worked for me

I'm afraid the proposed answer didn't work. I uninstalled and reinstalled PIP which also didn't work. Finally, I uninstalled and reinstalled both Python AND PIP and it worked. I have no idea what I did to it in the first place that could do such damage but that's what it took to fix it.

I have this problem in Pycharm, but when I try to run my py file by cmd, it can work. so I think this happens because Pycharm can't find the directory of certifi.

An easy way to solve this is to install certifi in Pycharm by Setting-> Projector Interpreter -> + to search the certifi and install it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM