Anaconda3 windows 下设置代理来获取包

        Anaconda 是一个用于科学计算的 Python 发行版,支持 Linux, Mac, Windows, 包含了众多流行的科学计算、数据分析的 Python 包。一般公司为了安全网络连接外网需要设置代理。如果不设置代理,将无法访问anaconda等python包的来源。

 

        方法一:修改anaconda的配置文件,位置在c:\User(或“用户”)\current_user(当前用户)\.condarc 下,增加如下内容:

channels:
  - http://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

show_channel_urls: true
allow_other_channels: true

proxy_servers:
  http: http://username:[email protected]:port
  https: http://username:[email protected]:port

ssl_verify: true
 

上述方法没有成功,无法联网获取包的来源。

 

          方法二:pip命令中加参数:pip --proxy http://XXXXX.com:端口, 其中代理是公司提供的IP地址和端口,如果需要账号验证,格式为:pip --proxy   http://username:[email protected]:port

          打开Anaconda Prompt,输入名利  pip --proxy   http://username:[email protected]:port  install pyinstaller

          发现仍然会报错,遇到There was a problem confirming the ssl certificate...的提示:

           这是因为国内墙的问题,可以使用就近的地址下载:
                       pip install xx -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

           最后的命令:pip --proxy   http://username:[email protected]:port  install pyinstaller  -i https://mirrors.aliyun.com/pypi/simple/      

            上述方法可以解决问题。

            备注:以上大部分内容参考网络。

          

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章