运行 带代理的 conda
Running conda with proxy
我在 windows 上使用 Anaconda 2.7,我的互联网连接使用代理。
以前,当使用 python 2.7(不是 Anaconda)时,我安装的包是这样的:
pip install {packagename} --proxy proxy-us.bla.com:123
有没有办法 运行 conda
使用代理参数?在 conda help
.
中没有看到它
谢谢
您可以通过将代理添加到 .condarc
来使用 conda 配置代理,例如
proxy_servers:
http: http://user:pass@corp.com:8080
https: https://user:pass@corp.com:8080
或设置 HTTP_PROXY
和 HTTPS_PROXY
环境变量。请注意,在您的情况下,您需要将方案添加到代理 url,例如 https://proxy-us.bla.com:123.
参见 http://conda.pydata.org/docs/config.html#configure-conda-for-use-behind-a-proxy-server。
我犯的一个错误是将文件保存为 a.condarc
或 b.condarc
。
仅将其另存为 .condarc
并将以下代码粘贴到文件中,并将文件保存在您的主目录中。对主机名、用户等进行必要的更改
channels:
- defaults
show_channel_urls: True
allow_other_channels: True
proxy_servers:
http: http://user:pass@hostname:port
https: http://user:pass@hostname:port
ssl_verify: False
或者您可以使用下面的 命令行 来自版本 4.4.x。
conda config --set proxy_servers.http http://id:pw@address:port
conda config --set proxy_servers.https https://id:pw@address:port
我能够在不输入用户名和密码的情况下让它工作:
conda config --set proxy_servers.https https://address:port
我解决的最佳方法是在之前使用conda
或[=14=设置代理环境变量] install/update 命令。只需 运行:
set HTTP_PROXY=http://username:password@proxy_url:port
例如,您的实际命令可能像
set HTTP_PROXY=http://yourname:your_password@proxy.your_company.com:8080
如果贵公司使用https代理,那么也
set HTTPS_PROXY=https://username:password@proxy_url:port
一旦退出 Anaconda 提示,此设置就会消失,因此您的 username/password 不会在会话结束后保存。
我没有选择 Anaconda documentation 中提到的其他方法或其他一些来源,因为它们都需要将 username/password 硬编码到
- Windows 环境变量(也是第一次需要重启Anaconda提示)
- Conda
.condarc
或 .netrc
配置文件(这也不适用于 PIP)
- A batch/script 文件在启动 Anaconda 提示时加载(这也可能需要配置路径)
这些都是不安全的,以后需要不断更新。如果您忘记在哪里更新?更多疑难解答将会出现...
您可以通过将代理添加到 .condarc 来使用 conda 配置代理,例如
proxy_servers:
http: http://user:pass@corp.com:8080
https: https://user:pass@corp.com:8080
然后在cmd Anaconda Power Prompt (base) PS C:\Users\user> 运行:
conda update -n root conda
在 Mac 上,对我有用的是去钥匙串并更新公司内部存储库的密钥密码。
我在 windows 上使用 Anaconda 2.7,我的互联网连接使用代理。
以前,当使用 python 2.7(不是 Anaconda)时,我安装的包是这样的:
pip install {packagename} --proxy proxy-us.bla.com:123
有没有办法 运行 conda
使用代理参数?在 conda help
.
谢谢
您可以通过将代理添加到 .condarc
来使用 conda 配置代理,例如
proxy_servers:
http: http://user:pass@corp.com:8080
https: https://user:pass@corp.com:8080
或设置 HTTP_PROXY
和 HTTPS_PROXY
环境变量。请注意,在您的情况下,您需要将方案添加到代理 url,例如 https://proxy-us.bla.com:123.
参见 http://conda.pydata.org/docs/config.html#configure-conda-for-use-behind-a-proxy-server。
我犯的一个错误是将文件保存为 a.condarc
或 b.condarc
。
仅将其另存为 .condarc
并将以下代码粘贴到文件中,并将文件保存在您的主目录中。对主机名、用户等进行必要的更改
channels:
- defaults
show_channel_urls: True
allow_other_channels: True
proxy_servers:
http: http://user:pass@hostname:port
https: http://user:pass@hostname:port
ssl_verify: False
或者您可以使用下面的 命令行 来自版本 4.4.x。
conda config --set proxy_servers.http http://id:pw@address:port
conda config --set proxy_servers.https https://id:pw@address:port
我能够在不输入用户名和密码的情况下让它工作:
conda config --set proxy_servers.https https://address:port
我解决的最佳方法是在之前使用conda
或[=14=设置代理环境变量] install/update 命令。只需 运行:
set HTTP_PROXY=http://username:password@proxy_url:port
例如,您的实际命令可能像
set HTTP_PROXY=http://yourname:your_password@proxy.your_company.com:8080
如果贵公司使用https代理,那么也
set HTTPS_PROXY=https://username:password@proxy_url:port
一旦退出 Anaconda 提示,此设置就会消失,因此您的 username/password 不会在会话结束后保存。
我没有选择 Anaconda documentation 中提到的其他方法或其他一些来源,因为它们都需要将 username/password 硬编码到
- Windows 环境变量(也是第一次需要重启Anaconda提示)
- Conda
.condarc
或.netrc
配置文件(这也不适用于 PIP) - A batch/script 文件在启动 Anaconda 提示时加载(这也可能需要配置路径)
这些都是不安全的,以后需要不断更新。如果您忘记在哪里更新?更多疑难解答将会出现...
您可以通过将代理添加到 .condarc 来使用 conda 配置代理,例如
proxy_servers:
http: http://user:pass@corp.com:8080
https: https://user:pass@corp.com:8080
然后在cmd Anaconda Power Prompt (base) PS C:\Users\user> 运行:
conda update -n root conda
在 Mac 上,对我有用的是去钥匙串并更新公司内部存储库的密钥密码。