一、配置conda源
1、 conda源更换为北京外国语大学
Anaconda 是一个用于科学计算的 Python 发行版,支持 Linux, Mac, Windows, 包含了众多流行的科学计算、数据分析的 Python 包。TUNA 还提供了 Anaconda 仓库与第三方源(conda-forge、msys2、pytorch等,查看完整列表)的镜像,各系统都可以通过修改用户目录下的 .condarc 文件:
windows系统
Windows 用户无法直接创建名为 .condarc 的文件,可先执行
conda config --set show_channel_urls yes 生成该文件之后再修改。
登录智星云windows云主机系统,打开conda控制台,在控制台执行
conda config --set show_channel_urls yes
然后执行dir命令,可以看到文件名.condarc 文件
在C:\Users\vipuser目录下编辑更改为以下源,用记事本打开,修改保存。
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.bfsu.edu.cn/anaconda/cloud
msys2: https://mirrors.bfsu.edu.cn/anaconda/cloud
bioconda: https://mirrors.bfsu.edu.cn/anaconda/cloud
menpo: https://mirrors.bfsu.edu.cn/anaconda/cloud
pytorch: https://mirrors.bfsu.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.bfsu.edu.cn/anaconda/cloud
simpleitk: https://mirrors.bfsu.edu.cn/anaconda/cloud
然后使用conda install xxxx安装需要的依赖包。
Linux系统
通过编辑/home/vipuser目录下~/.condarc文件
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.bfsu.edu.cn/anaconda/cloud
msys2: https://mirrors.bfsu.edu.cn/anaconda/cloud
bioconda: https://mirrors.bfsu.edu.cn/anaconda/cloud
menpo: https://mirrors.bfsu.edu.cn/anaconda/cloud
pytorch: https://mirrors.bfsu.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.bfsu.edu.cn/anaconda/cloud
simpleitk: https://mirrors.bfsu.edu.cn/anaconda/cloud
通过ssh连接的可以使用vim编辑器打开编辑
vim ~/.condarc修改完保存退出
2、注意如果需 要pytorch, 还需要添加pytorch的镜像:
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/
3、如果需要换回conda的默认源,直接删除channels即可,命令如下:
conda config --remove-key channels
补充:
不要使用清华源,清华源教育网好使,非教育网不好使
上海交通大学开源镜像站
channels:
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/main/
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/pkgs/free/
- https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/conda-forge/
ssl_verify: true
二、配置pip源
1、临时使用
pip install -i https://mirrors.bfsu.edu.cn/pypi/web/simple some-package
注意,simple 不能少, 是 https 而不是 http
windows下在命令行执行
Linux下如果conda 环境没有pip命令可以用conda install pip安装
2、设为默认
升级 pip 到最新的版本 (>=10.0.0) 后进行配置:
pip install pip -U pip config set global.index-url https://mirrors.bfsu.edu.cn/pypi/web/simple
补充:
阿里云镜像源
永久换源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
临时换源安装matplotlib
pip install -i https://mirrors.aliyun.com/pypi/simple/ matplotlib