在 Windows 上通过 .condarc 文件设置 Python Anaconda 代理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33883371/
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 14:08:39  来源:igfitidea点击:

Python Anaconda Proxy Setup via .condarc file on Windows

pythonproxyanacondaconda

提问by user914425

I am having trouble going through a proxy for Anaconda install conda on a Windows 7 machine. How do I use a proxy?

我在 Windows 7 机器上通过代理安装 Anaconda 时遇到问题。如何使用代理?

http://conda.pydata.org/docs/config.html

http://conda.pydata.org/docs/config.html

the above link is broken, use this one instead

上面的链接坏了,用这个代替

采纳答案by user914425

I had to create a .condarc file at the C:\Users\usernamefolder.

我必须在C:\Users\username文件夹中创建一个 .condarc 文件。

Use copy con .condarcfile if it does not exist at folder above.

copy con .condarc如果文件在上面的文件夹中不存在,请使用该文件。

File content is:

文件内容为:

proxy_servers:
    http: http://username:[email protected]:8080
    https: https://username:[email protected]:8080

Two notes:

两个注意事项:

  • Do not use tabs, there must be space between http:and http://...
  • You might not have a username and password for the proxy. Leave out the username:passwordpart and it will still work
  • 不要使用制表符,http:和之间必须有空格http://...
  • 您可能没有代理的用户名和密码。省略username:password部分,它仍然可以工作

回答by Andrushenko Alexander

On Windows 10 you need to set up additionally the domain name in the .condarc:

在 Windows 10 上,您需要在 .condarc 中额外设置域名:

channels:
  - admin

show_channel_urls: true
allow_other_channels: true

proxy_servers:
  http: http://domainname\username:password@proxyserver:port
  https: http://domainname\username:password@proxyserver:port

ssl_verify: true

回答by zheng

On windows 10 machine also. Following accepted answer's format gives a load error, invalid YAML.

在 Windows 10 机器上也是如此。按照接受的答案格式给出加载错误,无效的 YAML。

Changing '//' to '\' fixed the issue for me.

将 '//' 更改为 '\' 为我解决了这个问题。

proxy_servers:
  http: http:\username:[email protected]:8080
  https: https:\username:[email protected]:8080

回答by Bhagirath Kumar Lader

In my case on a linux machine behind a McAfee web-gateway proxy, only the following setup worked for conda (I removed the http proxy): hostname:~ # cat .condarc proxy_servers: https: https://domain\user:password@server:port

在我的情况下,在 McAfee 网络网关代理后面的 linux 机器上,只有以下设置适用于 conda(我删除了 http 代理):hostname:~ # cat .condarc proxy_servers: https: https://domain\user:password @服务器端口

hostname# conda install tensorflow Solving environment: done

hostname# conda install tensorflow 解决环境:done

Package Plan

套餐计划

environment location: /anaconda3

环境位置:/anaconda3

added / updated specs: - tensorflow

添加/更新规格: - tensorflow

The following packages will be downloaded:

将下载以下软件包:

package                    |            build
---------------------------|-----------------
markdown-3.0.1             |           py36_0         107 KB
gast-0.2.0                 |           py36_0          15 KB
libprotobuf-3.6.0          |       hdbcaa40_0         4.1 MB
protobuf-3.6.0             |   py36hf484d3e_0         610 KB
conda-4.5.12               |           py36_0         1.0 MB
termcolor-1.1.0            |           py36_1           7 KB
tensorflow-base-1.9.0      |mkl_py36h2ca6a6a_0        75.7 MB
grpcio-1.12.1              |   py36hdbcaa40_0         1.7 MB
astor-0.7.1                |           py36_0          43 KB
tensorboard-1.9.0          |   py36hf484d3e_0         3.3 MB
tensorflow-1.9.0           |mkl_py36h6d6ce78_1           3 KB
absl-py-0.6.1              |           py36_0         152 KB
_tflow_190_select-0.0.3    |              mkl           2 KB
------------------------------------------------------------
                                       Total:        86.7 MB

The following NEW packages will be INSTALLED:

将安装以下新软件包:

_tflow_190_select: 0.0.3-mkl
absl-py:           0.6.1-py36_0
astor:             0.7.1-py36_0
gast:              0.2.0-py36_0
grpcio:            1.12.1-py36hdbcaa40_0
libprotobuf:       3.6.0-hdbcaa40_0
markdown:          3.0.1-py36_0
protobuf:          3.6.0-py36hf484d3e_0
tensorboard:       1.9.0-py36hf484d3e_0
tensorflow:        1.9.0-mkl_py36h6d6ce78_1
tensorflow-base:   1.9.0-mkl_py36h2ca6a6a_0
termcolor:         1.1.0-py36_1

The following packages will be UPDATED:

以下软件包将被更新:

conda:             4.5.4-py36_0             --> 4.5.12-py36_0

Proceed ([y]/n)? y

继续 ([y]/n)?是

Downloading and Extracting Packages markdown-3.0.1 | 107 KB | ####################################### | 100% gast-0.2.0 | 15 KB | ####################################### | 100% libprotobuf-3.6.0 | 4.1 MB | ####################################### | 100% protobuf-3.6.0 | 610 KB | ####################################### | 100% conda-4.5.12 | 1.0 MB | ####################################### | 100% termcolor-1.1.0 | 7 KB | ####################################### | 100% tensorflow-base-1.9. | 75.7 MB | ####################################### | 100% grpcio-1.12.1 | 1.7 MB | ####################################### | 100% astor-0.7.1 | 43 KB | ####################################### | 100% tensorboard-1.9.0 | 3.3 MB | ####################################### | 100% tensorflow-1.9.0 | 3 KB | ####################################### | 100% absl-py-0.6.1 | 152 KB | ####################################### | 100% _tflow_190_select-0. | 2 KB | ####################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done

下载和解压包 markdown-3.0.1 | 107 KB | ##################################### | 100% gast-0.2.0 | 15 KB | ##################################### | 100% libprotobuf-3.6.0 | 4.1 MB | ##################################### | 100% protobuf-3.6.0 | 610 KB | ##################################### | 100% conda-4.5.12 | 1.0 MB | ##################################### | 100% termcolor-1.1.0 | 7 KB | ##################################### | 100% tensorflow-base-1.9。| 75.7 MB | ##################################### | 100% grpcio-1.12.1 | 1.7 MB | ##################################### | 100% astor-0.7.1 | 43 KB | ##################################### | 100% tensorboard-1.9.0 | 3.3 MB | ##################################### | 100% tensorflow-1.9。0 | 3 KB | ##################################### | 100% absl-py-0.6.1 | 152 KB | ##################################### | 100% _tflow_190_select-0。| 2 KB | ##################################### | 100% 准备交易:完成 验证交易:完成 执行交易:完成