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验证成功

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容