Running conda with proxy

Python 2.7ProxyAnaconda

Python 2.7 Problem Overview


I'm using Anaconda 2.7 on windows, and my internet connection uses a proxy.

Previously, when using python 2.7 (Not Anaconda), I installed package like this:

pip install {packagename} --proxy proxy-us.bla.com:123

Is there a way to run conda with proxy argument? didn't see it in conda help.

Thanks

Python 2.7 Solutions


Solution 1 - Python 2.7

You can configure a proxy with conda by adding it to the .condarc, like

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

or set the HTTP_PROXY and HTTPS_PROXY environment variables. Note that in your case you need to add the scheme to the proxy url, like https://proxy-us.bla.com:123.

See http://conda.pydata.org/docs/config.html#configure-conda-for-use-behind-a-proxy-server.

Solution 2 - Python 2.7

Or you can use the command line below from version 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

Solution 3 - Python 2.7

One mistake I was making was saving the file as a.condarc or b.condarc.

Save it only as .condarc and paste the following code in the file and save the file in your home directory. Make necessary changes to hostname, user etc.

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

Solution 4 - Python 2.7

I was able to get it working without putting in the username and password:

conda config --set proxy_servers.https https://address:port

Solution 5 - Python 2.7

The best way I settled with is to set proxy environment variables right before using conda or pip install/update commands. Simply run:

set HTTP_PROXY=http://username:password@proxy_url:port

For example, your actual command could be like

set HTTP_PROXY=http://yourname:[email protected]_company.com:8080

If your company uses https proxy, then also

set HTTPS_PROXY=https://username:password@proxy_url:port

Once you exit Anaconda prompt then this setting is gone, so your username/password won't be saved after the session.

I didn't choose other methods mentioned in Anaconda documentation or some other sources, because they all require hardcoding of username/password into

  • Windows environment variables (also this requires restart of Anaconda prompt for the first time)
  • Conda .condarc or .netrc configuration files (also this won't work for PIP)
  • A batch/script file loaded while starting Anaconda prompt (also this might require configuring the path)

All of these are unsafe and will require constant update later. And if you forget where to update? More troubleshooting will come your way...

Solution 6 - Python 2.7

You can configure a proxy with conda by adding it to the .condarc, like

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

Then in cmd Anaconda Power Prompt (base) PS C:\Users\user> run:

conda update -n root conda

Solution 7 - Python 2.7

On Mac what worked for me was going to keychain and updating the password for the key that for the company's the internal repo.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionomerbpView Question on Stackoverflow
Solution 1 - Python 2.7asmeurerView Answer on Stackoverflow
Solution 2 - Python 2.7su79eu7kView Answer on Stackoverflow
Solution 3 - Python 2.7SomitView Answer on Stackoverflow
Solution 4 - Python 2.7SunView Answer on Stackoverflow
Solution 5 - Python 2.7Frank WangView Answer on Stackoverflow
Solution 6 - Python 2.7VitView Answer on Stackoverflow
Solution 7 - Python 2.7Sumit ChauhanView Answer on Stackoverflow