Troubleshooting Pip Proxy Setup with CNTLM
While using CNTLM to configure pip for proxy access behind a company firewall, you may encounter errors like "Connection to proxy failed" or "Cannot fetch index." To effectively troubleshoot this issue, consider the following steps:
Verify CNTLM Setup
To check whether CNTLM is set up correctly, run the command:
cntlm.exe -c cntlm.ini -I -M http://google.com
If you receive a "Connection to proxy failed" error, review your CNTLM configuration settings and ensure that the proxy address and credentials are correct.
Use Environment Variables
Instead of using the --proxy option with pip, try setting the https_proxy environment variable to your proxy URL. Note that it should be https_proxy and not http_proxy.
export https_proxy=http://web-proxy.mydomain.com
Run Pip with Environment Variables
After setting the environment variable, run pip with the -E flag to use the modified environment settings:
sudo -E pip install somepackage
Credentials
The credentials to use are the ones you configured in the cntlm.ini file. Ensure that the username and password specified there match the credentials used by your company's proxy server.
Alternative Method
If CNTLM does not seem to resolve the issue, you can try using the following command to bypass the CNTLM proxy setup:
sudo pip -v install --proxy http://user:pass@localhost:3128 somepackage
Replace user and pass with the credentials from the cntlm.ini file.
Conclusion
By following these steps, you should be able to troubleshoot and successfully configure pip to use a proxy server with CNTLM. Remember to check your CNTLM setup, use the correct environment variable, and supply the appropriate credentials to establish a successful proxy connection for pip.
The above is the detailed content of How to Troubleshoot Pip Proxy Setup with CNTLM?. For more information, please follow other related articles on the PHP Chinese website!