如何告诉 Python 像 R 的 internet2 选项一样自动使用 Windows XP 中的代理设置? [英] How to tell Python to automatically use the proxy setting in Windows XP like R's internet2 option?

查看:45
本文介绍了如何告诉 Python 像 R 的 internet2 选项一样自动使用 Windows XP 中的代理设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是技术精湛的人.但我知道在 Windows 中,如果我使用 internet2 选项安装 R,那么我可以下载我想要的任何包.

I am not super technical person. But I know that in Windows if I install R using the internet2 option then I can download whatever package I want in it.

我安装了 Python,但每次尝试下载软件包或安装软件包(例如使用 easy_install)时,它都会失败.

I install Python and everytime I try to download a package or install a package (e.g. using easy_install) it fails.

如何让 Python 自动检测我的代理设置并只安装软件包?

What can I do to make Python automatically detect my proxy settings and just install the packages?

推荐答案

设置环境变量 http_proxy/https_proxyhttp://your-proxy-服务器地址:代理端口

Set up environment variable http_proxy / https_proxy to http://your-proxy-server-address:proxy-port

urlopen() 函数与代理透明地工作需要身份验证.在 Unix 或 Windows 环境中,设置http_proxy 或 ftp_proxy 环境变量到 URL在启动 Python 解释器之前识别代理服务器.例如('%' 是命令提示符):

The urlopen() function works transparently with proxies which do not require authentication. In a Unix or Windows environment, set the http_proxy, or ftp_proxy environment variables to a URL that identifies the proxy server before starting the Python interpreter. For example (the '%' is the command prompt):

% http_proxy="http://www.someproxy.com:3128"
% export http_proxy
% python
...

no_proxy 环境变量可以用来指定不应通过代理访问的主机;如果设置,它应该是一个以逗号分隔的主机名后缀列表,可选择使用 :port附加,例如cern.ch,ncsa.uiuc.edu,some.host:8080.

The no_proxy environment variable can be used to specify hosts which shouldn’t be reached via proxy; if set, it should be a comma-separated list of hostname suffixes, optionally with :port appended, for example cern.ch,ncsa.uiuc.edu,some.host:8080.

这篇关于如何告诉 Python 像 R 的 internet2 选项一样自动使用 Windows XP 中的代理设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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