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

25 投票
4 回答
86123 浏览
提问于 2025-05-10 23:13

我在Windows 7电脑上安装Anaconda的conda时,遇到了通过代理连接的问题。我该怎么用代理呢?

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

上面的链接坏了,换这个链接吧

相关文章:

  • 暂无相关问题
暂无标签

4 个回答

0

在我的情况下,我的Linux机器后面有一个McAfee网络网关代理,只有以下设置对conda有效(我去掉了http代理):

主机名:~ # cat .condarc

代理服务器:

https: https://domain\user:password@server:port

主机名# conda install tensorflow

解决环境:完成

软件包计划

环境位置:/anaconda3

添加/更新的规格:

- tensorflow

以下软件包将被下载:

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

以下新软件包将被安装:

_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

以下软件包将被更新:

conda:             4.5.4-py36_0             --> 4.5.12-py36_0

继续 ([y]/n)? y

正在下载和提取软件包

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%

准备事务:完成

验证事务:完成

执行事务:完成

0

在Windows 10电脑上,按照接受的答案格式会出现加载错误,提示YAML无效。

把'//'改成'\'就解决了我的问题。

proxy_servers:
  http: http:\username:password@corp.com:8080
  https: https:\username:password@corp.com:8080
7

在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
50

我需要在 C:\Users\username 文件夹里创建一个 .condarc 文件。

如果上面的文件夹里没有这个文件,可以使用 copy con .condarc 命令来创建。

文件的内容是:

proxy_servers:
    http: http://username:password@corp.com:8080
    https: https://username:password@corp.com:8080

有两点需要注意:

  • 不要使用制表符,http:http://... 之间必须有空格。
  • 你可能没有代理的用户名和密码。可以省略 username:password 这部分,文件依然可以正常工作。

撰写回答