You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Red Hat 8下pip3安装docker-compose失败问题求助

Fixing pip3 Connection Issues When Installing docker-compose on RHEL 8

Hey there, let's figure out why your pip3 can't connect to PyPI even with the proxy set up. That NewConnectionError: [Errno -2] Name or service not known error tells us pip can't reach or resolve the PyPI servers—and it's affecting all your pip installs, not just docker-compose. Here are actionable steps to fix this:

1. Validate Your Proxy Setup (and Fix Special Characters)

First, your proxy password includes ++, which are special characters in URLs. These need to be URL-encoded (replace + with %2B) for tools like pip and curl to recognize them correctly.

  • Test if your proxy can reach PyPI with curl (use encoded password):
    curl -x http://E10697:xxxxxx%2B%2B@10.162.64.36:8080 https://pypi.org/simple/docker-compose/
    
  • If this curl command fails, double-check your proxy server address, port, and account credentials—there’s likely an issue with the proxy itself (e.g., wrong port, expired password).

2. Configure pip to Use the Proxy Directly

Sometimes system environment variables for proxy don’t get picked up by pip reliably. Create a dedicated pip config file to ensure it uses your proxy:

For your user account (no sudo needed):

  1. Create the pip config directory if it doesn’t exist:
    mkdir -p ~/.config/pip
    
  2. Create ~/.config/pip/pip.conf with this content (use your encoded password):
    [global]
    proxy = http://E10697:xxxxxx%2B%2B@10.162.64.36:8080
    

If you need to use sudo:

Repeat the above steps for the root user—create /root/.config/pip/pip.conf with the same proxy line. This ensures pip uses the proxy even when run with sudo.

3. Check System DNS Resolution

The "Name or service not known" error can also mean your system can’t resolve PyPI’s domain names. Test this with:

nslookup pypi.org

If this returns an error, check your /etc/resolv.conf file to ensure it has valid DNS servers (ask your system admin for correct DNS settings if needed). Even with a proxy, the proxy server needs to resolve domain names, or your system needs to send DNS queries through the proxy.

4. Try a PyPI Mirror (If Proxy Issues Persist)

If you still can’t get the proxy working, use a domestic PyPI mirror to bypass the PyPI main server. Install docker-compose with:

pip3 install docker-compose --user -i https://mirrors.aliyun.com/pypi/simple/

Note: The --user flag avoids using sudo (which the warning recommends) and installs the package to your user directory instead of system-wide.

5. Verify the Fix

After trying the above steps, run the install command again:

pip3 install docker-compose --user

This should now connect to PyPI successfully and install docker-compose.

内容的提问来源于stack exchange,提问作者Arturo29

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:15:56