V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
taogen
V2EX  ›  Python

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

  •  
  •   taogen ·
    tagnja · 2023-04-17 11:57:55 +08:00 · 2596 次点击
    这是一个创建于 576 天前的主题,其中的信息可能已经有所发展或是发生改变。

    搞了一上午了,网上搜了很多方法都没解决。关掉代理,设置代理,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-04-17 12:45:08 +08:00
    删除 SSLKEYLOGFILE 变量之后可以了。可能之前我把那个变量指向的文件夹删除了
    第 2 条附言  ·  2023-04-17 12:50:37 +08:00
    十分感谢各位大佬的帮助
    15 条回复    2023-04-17 13:28:35 +08:00
    aru
        1
    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
        2
    raymanr  
       2023-04-17 12:05:34 +08:00
    换个源试试行不行 pip install -i https://pypi.douban.com/simple requests
    qwq11
        3
    qwq11  
       2023-04-17 12:07:58 +08:00
    Cannot connect to proxy 说你代理的问题吧,检查检查代理地址写对了吗,telnet/curl 试试呢。关掉代理不可能也是这个问题吧。你也可以 -i 走国内 pypi 的镜像
    iosyyy
        4
    iosyyy  
       2023-04-17 12:10:46 +08:00
    你代理没有启动或者代理配置的有问题
    taogen
        5
    taogen  
    OP
       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
        6
    Yourshell  
       2023-04-17 12:15:59 +08:00
    要不你先试一下在命令行下你的代理是否工作?
    taogen
        7
    taogen  
    OP
       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
        8
    taogen  
    OP
       2023-04-17 12:21:17 +08:00
    taogen
        9
    taogen  
    OP
       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
        10
    Yourshell  
       2023-04-17 12:25:11 +08:00
    raymanr
        12
    raymanr  
       2023-04-17 12:28:38 +08:00
    taogen
        13
    taogen  
    OP
       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
        14
    taogen  
    OP
       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
        15
    digimoon  
       2023-04-17 13:28:35 +08:00
    pip install pysocks
    pip install xxxx --proxy socks5://xxxx:1080
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5588 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 06:46 · PVG 14:46 · LAX 22:46 · JFK 01:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.