如何配置每个配置文件的PIP以使用代理(具有身份验证)? [英] How to configure PIP per config file to use a proxy (with authentification)?
问题描述
我过去曾经设置环境变量http_proxy和https_proxy(使用用户+密码)来在公司代理后面使用Pip(在Windows上).但是最近我需要告诉Pip使用代理而不设置环境变量,因为这与git配置和SSL证书相冲突,我只能通过删除代理的环境变量来工作.
I used to set up environment evariables http_proxy and https_proxy (with user + password) in the past to use Pip (on Windows) behind a corporate proxy. But recently I needed to tell Pip to use a proxy without setting up environment variables as this conflicted with git configuration in combination with SSL Certificates which I get to work only by removing environment variables for proxy.
幸运的是,您可以按如下所述使用pip.ini文件配置PIP: https://pip.pypa.io/zh-CN/stable/user_guide/#config-file
Fortunately you can configure PIP with an pip.ini file as described here: https://pip.pypa.io/en/stable/user_guide/#config-file
下面是我自己的问题的详细答案.
The detailed answer to my own question follows below.
推荐答案
以下是在pip的配置文件(pip.ini)中配置代理(带有身份验证)的步骤
Here are the steps how to configure proxy (with auth.) in pip's config file (pip.ini)
- (if it does not already exist) Create a folder named 'pip' and inside it a file named 'pip.ini' as described here: https://pip.pypa.io/en/stable/user_guide/#config-file (location an name may differ per platform - e.g. on Windows it's %APPDATA%\pip\pip.ini)
edit pip.ini file and add
[global]
proxy = http://user:password@proxy_name:port
具有身份验证(用户+密码)的代理的示例:
Example for proxy with authentification (user + password):
proxy = http://butch:secret @ proxyname:1234
代理名称也可以是IP地址
proxyname can be an IP adress, too
不带身份验证的代理的示例:
Example for proxy without auth.:
proxy = http://proxyname:1234
这篇关于如何配置每个配置文件的PIP以使用代理(具有身份验证)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!