如何使Anaconda在HTTP代理(而非https)后面工作?

问题描述 投票:13回答:6

我在Anaconda工作时遇到代理问题。

当我有以下环境变量时:

http_proxy: http://domain\username:[email protected]:8080
https_proxy: https://domain\username:[email protected]:8080

要不就

http_proxy: http://server\username:[email protected]:8080

然后设置git工作。但是Anaconda没有用。我想跑

conda update conda

我得到:

Could not connect to https://repo.continuum.io/pkgs....
Could not connect to https://repo.continuum.io/pkgs....

Anaconda不能使用http吗?并需要一个https代理?因为我认为我的公司可能没有设置https代理服务器(我只看到他们使用http)。或者有时我得到错误:

File "c\Anaconda2\", line 340, in wait
    waiter.acquire()
KeyboardInterrupt
Could not connect to https://repo.continuum.io/pkgs....
Could not connect to https://repo.continuum.io/pkgs....

我正在使用Windows 7。

python git proxy anaconda conda
6个回答
30
投票

您需要在Windows用户区域中创建.condarc文件:

C:\Users\<username>\

该文件应包含:

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://proxy.yourorg.org:port
    https: http://proxy.yourorg.org:port


ssl_verify: False

3
投票

我继续在环境变量中添加HTTP_proxy和HTTPS代理。使用的格式是“username:password @ proxy_name:port”。然后我重新打开了Anaconda提示。键入“set”以验证添加的变量是否存在于Anaconda环境中。现在,您可以在Ananconda提示符下键入“spyder”。这个设置对我有用。

最初我曾尝试使用代理参数设置“.condarc文件并尝试”conda update conda“,但没有运气。


2
投票

下面的工作让我永久设置Anaconda的代理:

转到C:/ ProgramData / Anaconda3 / etc /

如果它还没有conda文件夹,请创建它。

如果它还没有文件夹activate.d和deactive.d,请创建它们。

还要在两个文件夹中创建env_vars.bat。您的结束结构应如下所示:

enter image description here

在activate.d中的env_vars.bat中,粘贴以下内容(将其更改为您自己的代理):

set HTTP_PROXY=http://xx.xx.x.xx:xxxx/
set FTP_PROXY=http://xx.xx.x.xx:xxxx/
set HTTPS_PROXY=https://xx.xx.xxx.xx:xxxx/

在deactivate.d中的env_vars.bat中,粘贴以下内容(将变量留空):

set HTTP_PROXY=
set FTP_PROXY=
set HTTPS_PROXY=

关闭并重新打开Anaconda Prompt以激活更改。


1
投票

修改.condarc的上述解决方案对我不起作用。但是,我通过以高级系统设置更新环境变量,格式为https://user:[email protected]:8080

如果您的密码包含特殊字符,则需要按照维基百科上的百分比编码保留字符中的描述对其进行转义。 https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters


1
投票

如果上述解决方案对您不起作用,您可以试试这个。

转到您的PC设置,然后转到代理。只需为您的电脑全局提供代理设置即可。当我这样做时,它对我有用。

enter image description here


0
投票
© www.soinside.com 2019 - 2024. All rights reserved.