pycharm中引用requests库失败解决方法

概述:pycharm中想引用requests库,失败 ,遇到的3个大问题及解决方案如下:

(一)问题1:命令窗口中安装requests --- pip install requests 失败

提示:Requirement already satisfied (原因:因为和已存在的requests库冲突导致)

C:\Users\Administrator>pip install requests
Requirement already satisfied: requests in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (2.27.1)
Requirement already satisfied: idna<4,>=2.5 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from requests) (3.3)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from requests) (2.0.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from requests) (2021.10.8)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages (from requests) (1.26.8

解法1:pip install --target [指定路径] [指定包]

pip install --target c:\users\administrator\appdata\local\programs\python\python310\lib\site-packages requests

(二)问题2:使用指定路径安装requests仍提示错误:ValueError: check_hostname requires server_hostname  (原因:打开了fiddler使用代理导致)

 

【解法2】

关掉fiddler后问题解决!但是,又提示warning You should consider upgrading via the 'C:\Users\Administrator\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command. 

执行 C:\Users\Administrator\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command 后成功!

(三)问题3:安装requests成功,但是在pycharm中仍无法引用 

解法3】:在pycharm里面直接下载安装需要的库

File->settings->projetct->Python Interpreter 点击“+”,在Available Packages页面,搜索 requests -->Install Package

终于 成功引用!!

posted @ 2022-02-15 11:07  zzooZ  阅读(6038)  评论(0编辑  收藏  举报