[英]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文件“ C:\\ Local_PythonScripts \\ trial.py”,第2行,在
import requests汇入要求
File "C:\\Python36\\lib\\site-packages\\requests__init__.py", line 97, in文件“ C:\\ Python36 \\ lib \\ site-packages \\ requests__init __。py”,第97行,在
from .来自。 import utils
导入工具
File "C:\\Python36\\lib\\site-packages\\requests\\utils.py", line 24, in文件“ C:\\ Python36 \\ lib \\ site-packages \\ requests \\ utils.py”,第24行,在
from .来自。 import certs
进口证明
File "C:\\Python36\\lib\\site-packages\\requests\\certs.py", line 15, in第15行中的文件“ C:\\ Python36 \\ lib \\ site-packages \\ requests \\ certs.py”
from certifi import where从认证进口
ModuleNotFoundError: No module named 'certifi'ModuleNotFoundError:没有名为“ 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. 我想我自己是通过在命令控制台中的PIP上运行一些代码(这些代码是我从Stack Overflow复制而来的)而试图解决一个错误,该错误表示无法验证网页证书,这是我自己做的。 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: 我尝试删除并重新加载“请求”,但不会加载“ certifi”模块,在命令窗口中运行PIP后得到的相关文本为:
Could not fetch URL https://pypi.org/simple/certifi/ : There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443):
无法获取URL https://pypi.org/simple/certifi/ :确认ssl证书时出现问题: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)'),)) - skippingURL超过最大重试次数:/ simple / certifi /(由SSLError(SSLError(1,'[[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败(_ssl.c:777)'),)导致))-跳过
Could not find a version that satisfies the requirement certifi>=2017.4.17找不到满足certifi> = 2017.4.17要求的版本
(from requests) (from versions: )(来自请求)(来自版本:)
No matching distribution found for certifi>=2017.4.17 (from requests)找不到匹配的分布certifi> = 2017.4.17(来自请求)
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
. 首先,您可以安装
pip install certifi
然后使用此命令python -m pip install --upgrade pip
pip install certifi
升级您的python -m pip install --upgrade pip
然后尝试安装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.
我卸载并重新安装了PIP,但也没有用。 Finally, I uninstalled and reinstalled both Python AND PIP and it worked.
最终,我卸载并重新安装了Python AND PIP,它可以正常工作。 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. 我在Pycharm中有此问题,但是当我尝试通过cmd运行py文件时,它可以工作。 so I think this happens because Pycharm can't find the directory of certifi.
所以我认为这是因为Pycharm找不到certifi目录。
An easy way to solve this is to install certifi in Pycharm by Setting-> Projector Interpreter -> +
to search the certifi and install it. 解决此问题的一种简单方法是,通过
Setting-> Projector Interpreter -> +
在Pycharm中安装证书,以搜索并安装证书。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.