Python 使用 pip 实现代理感知

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30992717/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 09:17:40  来源:igfitidea点击:

Proxy awareness with pip

pythonproxypip

提问by Tom

I have tried to set up a python development environment at my work place to create some basic applications. I can't seem to get pip to work, for example I type in pip install numpyand get the following error message:

我尝试在我的工作场所建立一个 python 开发环境来创建一些基本的应用程序。我似乎无法让 pip 工作,例如我输入pip install numpy并收到以下错误消息:

  Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip
._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x035884B0>, 'Connection to pypi.python.
org timed out. (connect timeout=15)')': /simple/numpy/

The research I have done seems to indicate that proxy awareness is my issue, is this correct, if so I am not really sure on what this means exactly or how to resolve it.

我所做的研究似乎表明代理意识是我的问题,这是正确的,如果是这样,我不确定这究竟意味着什么或如何解决它。

采纳答案by Andy

If you know your proxy information, you can pass that to your command line:

如果您知道您的代理信息,您可以将其传递给您的命令行:

pip install --proxy=user:pass@server:port numpy

A full string could be something as simple as:

一个完整的字符串可能很简单:

pip install --proxy=http://proxy.example.com numpy

Where proxy.example.comis your (corporate) proxy server. You only need to pass user:passand portif the proxy also requires that information.

proxy.example.com您的(公司)代理服务器在哪里。您只需要通过,user:pass并且port代理也需要该信息。

回答by IndrajitDatta

This too works

这也有效

pip --proxy http://user:pass@server:port install libraryName

回答by The_Vats

pip doesn't work if you are using a proxy server for installing packages. To fix it: Go to control panel -> Internet options -> Connections ->LAN Settings ->Unmark 'use proxy server' options. Try using pip after this, it should work. You can start using proxy server after installing the package.

如果您使用代理服务器来安装软件包,则 pip 不起作用。要修复它:转到控制面板 -> Internet 选项 -> 连接 -> LAN 设置 -> 取消标记“使用代理服务器”选项。在此之后尝试使用 pip,它应该可以工作。安装软件包后,您可以开始使用代理服务器。

回答by Mahmoud Atallah

Just try the below

试试下面的

pip install --proxy=user:pass@server:port <package Name>

for example

例如

pip install --proxy=http://10.10.10.150/accelerated_pac_base.pac quandl 

回答by tomy_lee

Go to environment variables, and add 2 new variables: http_proxyand https_proxyto your proxy address. It's worked for me.

转到环境变量,并添加 2 个新变量: http_proxyhttps_proxy到您的代理地址。它对我有用。

回答by craq

I was getting this error message in a virtualbox, and tried every variation of the suggestions here to fix what appeared to be a proxy error. In the end it turned out that the time was set wrong within the virtual machine.

我在虚拟机中收到此错误消息,并尝试了此处建议的所有变体以修复似乎是代理错误的问题。最后发现是虚拟机中的时间设置错误。

回答by llywrch

I encountered the same issue. It turns out that the system time was wrong. Once I corrected the time, pip installed the module without a hitch.

我遇到了同样的问题。原来是系统时间不对。一旦我更正了时间,pip 就顺利安装了模块。

So, check to make sure that your system time is set correctly. It appears that pip does not work correctly when the clock is off.

因此,请检查以确保您的系统时间设置正确。时钟关闭时 pip 似乎无法正常工作。

回答by Praveen Patel G

Set proxy setting in Internet Explorer. Settings>Internet options>Connections>LAN Settings>Proxy Server

在 Internet Explorer 中设置代理设置。设置>Internet 选项>连接>局域网设置>代理服务器

->Check the checkBox and fill in your (system/organization) proxy settings

->选中复选框并填写您的(系统/组织)代理设置

No try your commands. It should work.

不试试你的命令。它应该工作。