python request及pip命令挂代理后报错ValueError: check_hostname requires server_hostname的真正解决方法

1先挂上代理

2获得本机代理端口

C:\Users\Administrator>python
Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib.request import getproxies
>>> getproxies()
{'https': 'http://127.0.0.1:11000', 'http': 'http://127.0.0.1:11000'}
此处获得代理端口为11000

3创建环境变量

HTTP_PROXY: http://127.0.0.1:11000
HTTPS_PROXY: http://127.0.0.1:11000


image.png

4重启命令提示行,在挂代理的情况下使用pip验证成功

你可能感兴趣的:(python request及pip命令挂代理后报错ValueError: check_hostname requires server_hostname的真正解决方法)