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

2023-04-17 11:57:55 +08:00
 taogen

搞了一上午了,网上搜了很多方法都没解决。关掉代理,设置代理,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)
2067 次点击
所在节点    Python
15 条回复
aru
2023-04-17 12:05:10 +08:00
你改了 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
2023-04-17 12:05:34 +08:00
换个源试试行不行 pip install -i https://pypi.douban.com/simple requests
qwq11
2023-04-17 12:07:58 +08:00
Cannot connect to proxy 说你代理的问题吧,检查检查代理地址写对了吗,telnet/curl 试试呢。关掉代理不可能也是这个问题吧。你也可以 -i 走国内 pypi 的镜像
iosyyy
2023-04-17 12:10:46 +08:00
你代理没有启动或者代理配置的有问题
taogen
2023-04-17 12:14:04 +08:00
@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
2023-04-17 12:15:59 +08:00
要不你先试一下在命令行下你的代理是否工作?
taogen
2023-04-17 12:20:52 +08:00
命令行设置代理 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
2023-04-17 12:21:17 +08:00
taogen
2023-04-17 12:24:28 +08:00
OSError: Missing dependencies for SOCKS support. 是不是要下载源码安装 urllib3 啊,我之前看网上是这样说的。

$ git clone https://github.com/urllib3/urllib3.git
$ cd urllib3
$ pip install .
Yourshell
2023-04-17 12:25:11 +08:00
NoOneNoBody
2023-04-17 12:25:34 +08:00
raymanr
2023-04-17 12:28:38 +08:00
taogen
2023-04-17 12:35:57 +08:00
@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
2023-04-17 12:42:50 +08:00
@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
2023-04-17 13:28:35 +08:00
pip install pysocks
pip install xxxx --proxy socks5://xxxx:1080

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/933108

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX