如何配置每个配置文件的PIP以使用代理(具有身份验证)? [英] How to configure PIP per config file to use a proxy (with authentification)?

查看:128
本文介绍了如何配置每个配置文件的PIP以使用代理(具有身份验证)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我过去曾经设置环境变量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)

  1. (如果尚不存在),创建一个名为"pip"的文件夹,并在其中创建一个名为"pip.ini"的文件,如下所述:
  1. (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)
  2. 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屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆