如何使用anaconda python启用代理服务器?

时间:2015-03-25 22:20:02

标签: python proxy firewall anaconda

我们正试图让conda安装(在Windows 8上)通过代理服务器在防火墙后面工作。目前,我们可以使用pip在公司网络上安装软件包,方法是在命令提示符处使用:

pip install pandas --proxy=http://abc.def.xyz.com:1234

不需要指定密码,只需指定代理服务器和端口。 conda documentation表示代理服务器是可能的:

# Proxy settings: http://[username]:[password]@[server]:[port]
proxy_servers:
    http: http://user:pass@corp.com:8080
    https: https://user:pass@corp.com:8080

我已经尝试了各种组合,看看我是否可以使用或不使用我的用户名和密码。

# formats tried:
http: http://user:pass@abc.def.xyz.com:1234
http: http://abc.def.xyz.com:1234

我似乎无法让它发挥作用。尝试了引用事物的各种组合(密码有特殊字符)。也尝试使用和不使用域\用户。

我可以在引擎盖下看到,conda正在使用urlib3(而pip可能正在使用urlib proxy handler?)。请注意,在文件中包含您的用户名和密码通常是不受欢迎的。

我知道我们可以设置我们自己的http或文件位置通道,并将所有包放在那里,并将通道添加到.condarc配置设置。但是,我宁愿不必在本地管理包和版本的存储库。

所以....有没有办法在.condarc文件中指定代理服务器和端口(没有用户和密码),这样conda安装就像在命令行上的pip install一样在防火墙后工作?或者甚至像pip这样的内联调用都具有以下功能......例如:

conda install pandas --proxy=abc.def.xyz.com:1234

提前致谢...

PS:我真的很喜欢康达。我上周末在家用电脑上设置了许多虚拟环境。文档很棒,一切都运行完美。总的来说,比pip​​要好得多......如果我们只能在公司内部工作:)

7 个答案:

答案 0 :(得分:13)

嗯,这是令人尴尬的,但好消息。我通过再次尝试更改condarc文件解决了我的问题。

https: https://abc.def.xyz.com:1234

我猜pip与普通的http工作正常,而conda的地址都是https网站:

https://repo.continuum.io/pkgs/free/win-64/

我应该抓住那个!

好吧,我现在很高兴我们有一个解决方案,在我们的防火墙后面使用conda,而且不需要用户和密码。真棒!

答案 1 :(得分:5)

迟到的答案,但也许其他人面临这个问题可能会受益。

创建.condarc文件contaninig:

channels:
- defaults

# Show channel URLs when displaying what is going to be downloaded and
# in 'conda list'. The default is False.
show_channel_urls: True
allow_other_channels: True

proxy_servers:
    http: http://172.**.*.***:8080
    https: https://172.**.*.***:8080


ssl_verify: False

使用您自己的代理设置更改IP地址。

将此文件放在用户的主文件夹中(对我来说:C:\ Users \ bakayim)

重新启动anaconda提示

答案 2 :(得分:0)

以下.condarc文件

为我提供了什么
channels:
  - r
  - defaults

proxy_servers:
  http: http://username:password@Proxyadresse:Proxyport
  https: https://username:password@Proxyadresse:Proxyport

ssl_verify: true

答案 3 :(得分:0)

我还设置了2个Windows环境变量:(不知道是否有必要)

gpg2 --list-secret
gpg --list-secret

变量:http://username:password@Proxyadresse:Proxyport

Name: http_proxy

变量:https://username:password@Proxyadresse:Proxyport

答案 4 :(得分:0)

我可以确认.condarc在我的情况下没有预期的效果(Windows 7)。使用conda info我可以验证它已加载但它没有任何效果。

我必须设置前面提到的环境变量才能从代理后面获得连接。

我在命令提示符下完成了以下操作:

set http_proxy=[protocol:your_proxy_address_here:port]
set https_proxy=[protocol:your_proxy_address_here:port]

删除括号。要验证(列出)您的并发设置,只需输入:设置

答案 5 :(得分:0)

打开Anaconda命令并执行以下命令:

set HTTP_PROXY=http://username:password@proxyurl.com:8080

set HTTPS_PROXY=https://username:password@proxyurl.com:8443

答案 6 :(得分:-1)

Anaconda的新版本附带用户目录C:\Users\User_name\.condarc中的.condar文件。

所以要做的就是编辑内容如下:

channels:
  - defaults

show_channel_urls: True
allow_other_channels: True

proxy_servers:
    http: http://172.**.*.***:8080
    https: https://172.**.*.***:8080

ssl_verify: true

这对我有用。