current position:Home>Problems encountered in Python + requests + pytest: post request error: check_ hostname requires server_ hostname

Problems encountered in Python + requests + pytest: post request error: check_ hostname requires server_ hostname

2022-02-02 15:05:09 adorable_

Recently built on the computer python Environmental Science , Match environment variables , Then install requests plug-in unit , After running the code, I found that there was an error :
 Insert picture description here

Reasons for reporting errors :

   This is actually the same as the selected one python The version doesn't matter much , The main reason is because every time you use pip install Command to download the plug-in , Download the latest version , For example, download. requests plug-in unit , It will automatically depend on urllib3 This plug-in is also installed , Then the version of the plug-in that you depend on is too high , This leads to the problem of error reporting .

   So , Generally, when we encounter this kind of inexplicable problem , You can go to see if it is caused by plug-in problems , The solution is to urllib3 The plug-in version can be reduced , Of course , Direct installation at requests Plug-in time , Choosing a lower version can also solve this problem . For example, use the following command to specify the version to install :

pip install requests==2.20
 perhaps 
pip install urllib3==1.25.8

In the use of pip The following error messages may appear when installing plug-ins :
 Insert picture description here
The above reason is mainly the website pypi.python.org It's been blocked at home , Unable to install the program from Python Caused by downloading materials from the official website , The solution is to use other image sources to install , Such as :

pip install requests==2.20 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

 Insert picture description here
attach : Domestic mirror source

Source Address
Alibaba cloud http://mirrors.aliyun.com/pypi/simple/
University of science and technology of China https://pypi.mirrors.ustc.edu.cn/simple/
douban http://pypi.douban.com/simple
Python official https://pypi.python.org/simple/
v2ex http://pypi.v2ex.com/simple/
Chinese academy of sciences http://pypi.mirrors.opencas.cn/simple/
Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/

copyright notice
author[adorable_],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/02/202202021505067777.html

Random recommended