关于python 3.x:如何在(linux)ubuntu16.04上设置anaconda的代理

How to set the proxy of anaconda on (linux) ubuntu16.04

我正在ubuntu 16.04上配置anaconda。
当我使用conda update --all时,出现如下错误

Fetching package metadata ...
CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://repo.continuum.io/pkgs/main/linux-64/repodata.json.bz2
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
ProxyError(MaxRetryError("HTTPSConnectionPool(host='repo.continuum.io', port=443): Max retries exceeded with url: /pkgs/main/linux-64/repodata.json.bz2 (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary >failure in name resolution',)))",),)

也许在anaconda上需要新的代理设置,但是,ubuntu 16.04已设置代理。

我在网上看到我应该将代理添加到包含代理地址的.condarc文件中。不幸的是,

  • 我在Ubuntu 16.04上找不到.condarc文件
  • 还是有解决错误的另一种方法?
  • 感谢任何帮助,谢谢!


    在主目录中创建一个新文件~/.condarc

    1
    $ nano ~/.condarc

    将以下这些行添加到.condarc文件中

    1
    2
    3
    proxy_servers:
        http: http://user:[email protected]:8080
        https: https://user:[email protected]:8080

    如果您的密码包含特殊字符,则需要按照Wikipedia上的百分比编码保留字符中的说明进行转义。
    有时,由于其回购中发布了一些错误,conda命令在添加这些内容后不起作用。如果是这样,则删除.condarc文件,然后尝试使用这些命令

    1
    2
    $ export HTTP_PROXY=http://user:[email protected]:8080
    $ export HTTPS_PROXY=https: https://user:[email protected]:8080

    该方法有时不起作用,但仍然值得一试。
    希望这可以帮助。对于任何查询,请在评论部分中找到。