How to make Anaconda work behind HTTP proxy (not https)?

前端 未结 7 1934
攒了一身酷
攒了一身酷 2020-12-14 18:42

I\'m having trouble working with Anaconda behind a proxy at work.

When I have have the following environment variables:

http_proxy: http://domain\\us         


        
相关标签:
7条回答
  • 2020-12-14 19:18

    you need to create a .condarc file in you Windows user area:

    C:\Users\<username>\
    

    The file should contain:

    channels:
    - defaults
    
    # Show channel URLs when displaying what is going to be downloaded and
    # in 'conda list'. The default is False.
    show_channel_urls: True
    allow_other_channels: True
    
    proxy_servers:
        http: http://proxy.yourorg.org:port
        https: http://proxy.yourorg.org:port
    
    
    ssl_verify: False
    
    0 讨论(0)
  • 2020-12-14 19:22

    The below worked for me to permanently set my proxies for Anaconda:

    Go to C:/ProgramData/Anaconda3/etc/

    If it doesn’t already have a conda folder, create it.

    If it doesn’t already have the folders activate.d and deactive.d, create them.

    Also create env_vars.bat in both folders. Your end structure should look like the snapshot below:

    In env_vars.bat in activate.d, paste the following (change it to your own proxies):

    set HTTP_PROXY=http://xx.xx.x.xx:xxxx/
    set FTP_PROXY=http://xx.xx.x.xx:xxxx/
    set HTTPS_PROXY=https://xx.xx.xxx.xx:xxxx/
    

    In env_vars.bat in deactivate.d, paste the following (leave the variables blank):

    set HTTP_PROXY=
    set FTP_PROXY=
    set HTTPS_PROXY=
    

    Close and reopen your Anaconda Prompt to activate the changes.

    0 讨论(0)
  • 2020-12-14 19:23

    Worked for me with certificate yourcertname.pem: https://aafaqueabdullah.wordpress.com/2017/04/10/ssl-authentication/

    0 讨论(0)
  • 2020-12-14 19:24

    If the above solutions didnt work for you, you can try this.

    Go to your PC settings and then to proxy. Just give the proxy setting globally for your pc. When I did it, it worked for me.

    0 讨论(0)
  • 2020-12-14 19:28

    See my answer in another post:

    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:your_password@proxy.your_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...

    0 讨论(0)
  • 2020-12-14 19:30

    The above solution of modifying .condarc doesn't work for me. However I succeed by updating the environment variables in Advanced System Settings in the format https://user:pass@corp.com:8080.

    If your password contains special characters, you need escape them as described in Percent-encoding reserved characters , on Wikipedia. https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters

    0 讨论(0)
提交回复
热议问题