Pycharm 配置 Conda,国内使用正确的镜像源地址

Pycharm 配置 Conda,国内使用正确的镜像源地址,第1张

开始使用 Pycharm,搭配Conda做包管理,按照网上教程使用过程中发现镜像源不管是阿里的还是清华的都会有404异常,花了点时间找到正确的配置方式。记录一下备忘。

参考链接:

  1. https://blog.csdn.net/weixin_42425256/article/details/105099769
  2. https://blog.csdn.net/weixin_39918690/article/details/110606097
  3. https://www.cnblogs.com/tianlang25/p/12433025.html
  4. https://www.cnblogs.com/zengming/p/12057656.html

问题出在镜像源的链接上,网上教程大部分是类似这种:

https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/

但其实打开链接后会发现下面还有一层,如下:

这里面是各种平台,正确的链接应该再加上对应的平台。例如mac系统64位的配置是这样:

https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/osx-64/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/osx-64/

windows 64位系统是这样:

https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/

贴一下我的配置,据说上海交大源比较全,因此我的配置中交大源优先。

/Users/xxx/.condarc

show_channel_urls: true
channels:
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/osx-64/
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/osx-64/
  - https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/osx-64/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/osx-64/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/osx-64/
ssl_verify: true

某些包通过Conda下不到的,再通过pip install -i 指定临时镜像安装。例如:

pip install -i http://mirrors.aliyun.com/pypi/simple opencv-contrib-python==3.4.2.17 --trusted-host mirrors.aliyun.com

嫌麻烦也可以永久修改配置镜像源,如下:

pip config set global.index-url https://mirror.sjtu.edu.cn/pypi/web/simple

或者创建或编辑 ~/.config/pip/pip.conf 文件,加入或修改 index-url 相关段落为:

[global]
index-url = https://mirror.sjtu.edu.cn/pypi/web/simple
format = columns

不完全统计,pip的国内镜像源如下:

上海交通大学 https://mirror.sjtu.edu.cn/pypi/web/simple
阿里云    http://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/

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/726705.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-26
下一篇 2022-04-26

发表评论

登录后才能评论

评论列表(0条)

保存