1. 程式人生 > >anaconda設定代理以及新增映象源

anaconda設定代理以及新增映象源

公司為了安全,網路連線外網需要設定代理。因此,如果不設定代理,將無法訪問anaconda等python包的來源。進行如下操作:

1.開啟Anaconda Prompt,先新增國內映象源

在這裡插入圖片描述
一些國內映象源:

  阿里雲 https://mirrors.aliyun.com/pypi/simple/
  中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/
  豆瓣(douban) http://pypi.douban.com/simple/
  清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
  中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/

新增映象源命令:

conda config --add channels https://mirrors.aliyun.com/pypi/simple/

檢視新增的映象:
conda config --get channels

2.設定可以使用pip訪問包管理,執行如下命令:

conda config --set use_pip True

3.修改anaconde的配置檔案.condarc,一般在如下目錄:

在這裡插入圖片描述
C:\Users\18030501.condarc

4.將如下內容寫入.condarc檔案:

其中host:port為ip+埠,若公司代理是域名,那就是域名+埠(

xxx.com:port)

proxy_servers:
    http: http://host:port
    https: http://host:port

參考:
https://stackoverflow.com/questions/29267646/how-to-enable-proxy-servers-with-anaconda-python