Skip to content

Instantly share code, notes, and snippets.

@HoriLiu
Created January 10, 2017 01:28
Show Gist options
  • Save HoriLiu/aa091f2cbcf3ff0ebc193eb65c6b2e3e to your computer and use it in GitHub Desktop.
Save HoriLiu/aa091f2cbcf3ff0ebc193eb65c6b2e3e to your computer and use it in GitHub Desktop.
Python Anaconda Proxy Setup via .condarc file on Windows
#Create a .condarc file at: C:\Users\username folder.
http://conda.pydata.org/docs/config.html#the-conda-configuration-file-condarc
Example: conda config --add channels r
use copy con .condarc file if does not exist at above folder.
File content is:
proxy_servers:
http: http://username:password@corp.com:8080
https: https://username:password@corp.com:8080
(DO NOT USE tabs, must be space between http: and http://...)
You might not have a username and password for proxy still works.
@tidypy
Copy link

tidypy commented May 3, 2019

!!Writing into the text file .condarc will corrupt the file and Anaconda navigator will not load until you delete it.
you must launch Spyder; then edit through command line using command below:
use the syntax exactly only change the [username,password@corp.com:Port8080] , do not change any other syntax.

  • First create a copy of the .condarc file.

  • Next open the .condarc file in Spyder.

  • now go to command line and enter:

conda config --set proxy_servers http: 'http://username:password@corp.com:8080/'
conda config --set proxy_servers https: 'https://username:password@corp.com:8080/'
at that point Spyder will edit the .condarc file. check this by clicking the .condarc file in Spyder; it should prompt you to refresh and new text should appear. If not; the syntax is wrong.

**Now the file will be available for manual Edit. Now you can type the below data manually into the file.
**Pay attention to the syntax: each space and quote is crucial. remove junk characters from the file such as '?' and ':'
You Must have a "/" at the end of your proxy link. this is written. in the anaconda documentation for config of proxy.
If you do not need username/password. use this setup with the --ssl_verify switch set to false
if you require a password set the switch to True; and it will prompt you for a password. (if you have dual monitor look out for the pop up).
if your company proxy uses only one HTTP address; enter this address into both HTTP and HTTPS lines.

conda config --set ssl_verify false
Edit the .condarc file manually and add this:
proxy_servers:
http: http://proxy.corp.com:8080/
https: https://proxy.corp.com:8080/

you should be good to go;
Test this by doing an update; type the following and wait about 3 minutes:
conda update -n root conda

Good luck:
I will note that your corporate "IT" will not typically make a firewall exception for you to bypass proxy; and you must use a proxy.
Therefore with the proper proxy info; this should work.
The day Anaconda incorporates "AutoDetect Proxy"; ....hmmmm afterthought?

@tidypy
Copy link

tidypy commented May 3, 2019

another quirk I found is that you can actually have "ssl_verify = true" depending on the proxy script you may actually will require it, even if you in fact do not need a password.
in this case it will prompt you for a password. This method is preferred to entering your full usrname/passwrd in the text file.
and when your password changes you do not need to go through this process agian with .condarc pains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment