taogen
V2EX  ›  Python

大佬们,求助 pip install 出现 ProxyError 如何解决啊

By taogen at 2023 年 4 月 17 日 · 4832 次点击

搞了一上午了,网上搜了很多方法都没解决。关掉代理,设置代理,python 卸载重装等也不行。头痛欲裂。

$ pip install requests
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
ERROR: Could not find a version that satisfies the requirement requests (from versions: none)
ERROR: No matching distribution found for requests
WARNING: There was an error checking the latest version of pip.

python 和 pip 都是最新版

$ python -V
Python 3.11.3
$ pip -V
pip 22.3.1 from D:\python-3.11\Lib\site-packages\pip (python 3.11)
第 1 条附言  ·  2023 年 4 月 17 日
删除 SSLKEYLOGFILE 变量之后可以了。可能之前我把那个变量指向的文件夹删除了
第 2 条附言  ·  2023 年 4 月 17 日
十分感谢各位大佬的帮助
16 条回复  •  2025-02-24 10:14:12 +08:00
aru
   1
aru  
   2023 年 4 月 17 日
你改了 pip 的镜像配置么?
先试试下面命令能不能安装
pip install -i https://mirrors.ustc.edu.cn/pypi/web/simple requests

如果可以,再执行下面命令
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple
raymanr
   2
raymanr  
   2023 年 4 月 17 日
换个源试试行不行 pip install -i https://pypi.douban.com/simple requests
shxxy
   3
shxxy  
   2023 年 4 月 17 日
Cannot connect to proxy 说你代理的问题吧,检查检查代理地址写对了吗,telnet/curl 试试呢。关掉代理不可能也是这个问题吧。你也可以 -i 走国内 pypi 的镜像
iosyyy
   4
iosyyy  
   2023 年 4 月 17 日
你代理没有启动或者代理配置的有问题
taogen
   5
taogen  
OP
   2023 年 4 月 17 日
@aru @raymanr 开着 v2ray 代理指定了源还是 ProxyError ,关掉代理变成了 ProtocolError 。

$ pip install -i https://pypi.douban.com/simple requests
Looking in indexes: https://pypi.douban.com/simple
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
ERROR: Could not find a version that satisfies the requirement requests (from versions: none)
ERROR: No matching distribution found for requests
WARNING: There was an error checking the latest version of pip.
Yourshell
   6
Yourshell  
   2023 年 4 月 17 日
要不你先试一下在命令行下你的代理是否工作?
taogen
   7
taogen  
OP
   2023 年 4 月 17 日
命令行设置代理 export ALL_PROXY=socks5://127.0.0.1:1080 后可以访问 google 了

$ curl -s https://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>

现在的错误是 OSError: Missing dependencies for SOCKS support.

$ pip install -i https://mirrors.ustc.edu.cn/pypi/web/simple requests
Looking in indexes: https://mirrors.ustc.edu.cn/pypi/web/simple
ERROR: Could not install packages due to an OSError: Missing dependencies for SOCKS support.

$ pip install requests
ERROR: Could not install packages due to an OSError: Missing dependencies for SOCKS support.
taogen
   8
taogen  
OP
   2023 年 4 月 17 日
taogen
   9
taogen  
OP
   2023 年 4 月 17 日
OSError: Missing dependencies for SOCKS support. 是不是要下载源码安装 urllib3 啊,我之前看网上是这样说的。

$ git clone https://github.com/urllib3/urllib3.git
$ cd urllib3
$ pip install .
Yourshell
   10
Yourshell  
   2023 年 4 月 17 日
raymanr
   12
raymanr  
   2023 年 4 月 17 日
taogen
   13
taogen  
OP
   2023 年 4 月 17 日
@raymanr 好像不支持 socks 的代理

$ pip install requests --proxy 'socks://127.0.0.1:1080'
ERROR: Could not install packages due to an OSError: Missing dependencies for SOCKS support.
taogen
   14
taogen  
OP
   2023 年 4 月 17 日   ❤️ 1
@NoOneNoBody 删除 SSLKEYLOGFILE 变量可以了

$ pip install requests
Collecting requests
Downloading requests-2.28.2-py3-none-any.whl (62 kB)
-------------------------------------- 62.8/62.8 kB 674.1 kB/s eta 0:00:00
Collecting charset-normalizer<4,>=2
Downloading charset_normalizer-3.1.0-cp311-cp311-win_amd64.whl (96 kB)
---------------------------------------- 96.7/96.7 kB 1.4 MB/s eta 0:00:00
Collecting idna<4,>=2.5
Downloading idna-3.4-py3-none-any.whl (61 kB)
---------------------------------------- 61.5/61.5 kB ? eta 0:00:00
Collecting urllib3<1.27,>=1.21.1
Downloading urllib3-1.26.15-py2.py3-none-any.whl (140 kB)
-------------------------------------- 140.9/140.9 kB 4.1 MB/s eta 0:00:00
Collecting certifi>=2017.4.17
Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
-------------------------------------- 155.3/155.3 kB 9.1 MB/s eta 0:00:00
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
Successfully installed certifi-2022.12.7 charset-normalizer-3.1.0 idna-3.4 requests-2.28.2 urllib3-1.26.15

[notice] A new release of pip available: 22.3.1 -> 23.1
[notice] To update, run: python.exe -m pip install --upgrade pip
digimoon
   15
digimoon  
   2023 年 4 月 17 日
pip install pysocks
pip install xxxx --proxy socks5://xxxx:1080
RyougiShiki
   16
RyougiShiki  
   2025 年 2 月 24 日
14 楼正解。我的情况是官方源和国内源可浏览器访问看到包列表,同一局域网的另一台机器可访问。所以一直在排查代理和 ssl 。之前换下国内源就好了,这次由于是由于 ssl 问题排查了一会还是靠 V 站解决了。
推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
© 2026 V2EX · 39ms · 3.9.8.5