如何使点子在代理服务器后面工作 [英] How to get pip to work behind a proxy server

查看:82
本文介绍了如何使点子在代理服务器后面工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用python软件包管理器pip安装软件包,并且它是来自互联网的依赖项.但是,我在大学里的代理服务器后面,并且已经设置了http_proxy环境变量.但是当我尝试安装这样的软件包时:

I am trying to use python package manager pip to install a package and it's dependencies from the internet. However I am behind a proxy in my college and have already set the http_proxy environment variable. But when I try to install a package like this:

pip install TwitterApi

我在日志文件中收到此错误:

I get this error in the log file:

Getting page http://pypi.python.org/simple/TwitterApi
Could not fetch URL http://pypi.python.org/simple/TwitterApi: <urlopen error [Errno 111] Connection refused>
Will skip URL http://pypi.python.org/simple/TwitterApi when looking for download links for TwitterApi
Getting page http://pypi.python.org/simple/
Could not fetch URL http://pypi.python.org/simple/: <urlopen error [Errno 111] Connection refused>

我什至尝试像这样显式设置代理变量:

I even tried setting my proxy variable explicitly like this:

pip install --proxy http://user:password@proxyserver:port TwitterApi

但是我仍然遇到相同的错误.如何获得在代理服务器后面工作的点子.

But I still get the same error. How do I get pip to work behind a proxy server.

推荐答案

根据pip --help,pip的proxy参数的格式为scheme://[user:passwd@]proxy.server:port

The pip's proxy parameter is, according to pip --help, in the form scheme://[user:passwd@]proxy.server:port

您应使用以下内容:

pip install --proxy http://user:password@proxyserver:port TwitterApi

此外,还应遵守HTTP_PROXY env var.

Also, the HTTP_PROXY env var should be respected.

请注意,在早期版本中(无法跟踪代码中的更改,抱歉,但是文档已更新此处),则必须将scheme://部分保留下来才能工作,即pip install --proxy user:password@proxyserver:port

Note that in earlier versions (couldn't track down the change in the code, sorry, but the doc was updated here), you had to leave the scheme:// part out for it to work, i.e. pip install --proxy user:password@proxyserver:port

这篇关于如何使点子在代理服务器后面工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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