conda和pip加速参考

conda install和创建虚拟环境下载慢,可以修改/root/.condarc文件:

vim /root/.condarc

各系统都可以通过修改用户目录下的 .condarc 文件。Windows 用户无法直接创建名为 .condarc 的文件,

可先执行 conda config --set show_channel_urls yes 生成该文件之后再修改。

把下面的粘贴进去,注意缩进:

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.bfsu.edu.cn/anaconda
default_channels:
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/free
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/pro
  - 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
  simpleitk: https://mirrors.bfsu.edu.cn/anaconda/cloud
  viscid-hub: https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
  atztogo: https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
  fastai: https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/
  atztogo: https://mirrors.sjtug.sjtu.edu.cn/anaconda/cloud/

 

然后,设置搜索时显示通道地址(上述 .condarc文件中的"show_channel_urls: true"已经设置,如果没设置可用以下命令设置):

运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。

conda config --set show_channel_urls yes

conda config --show #从打查看配置信息,看一下url有没有更新

或者参考:https://mirrors.bfsu.edu.cn/help/anaconda/ 或 https://mirrors.njupt.edu.cn/help/anaconda/

 

恢复默认源头

有时候可能国内镜像在某些特殊的情况下会出问题,使用下面的命令来恢复到默认

conda config --remove-key channels

conda查看配置信息

conda config --show

pip更换清华大学源

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 

然后,安装包时,可以看到包的源发生了变化。
在这里插入图片描述
pip
在pip install ***后面加上
-i https://pypi.tuna.tsinghua.edu.cn/simple #这个也可以用163或网易的。
无敌好用。

conda config --set show_channel_urls yes
pytorch官方安装的命令是(以版本1.4 GPU为例):
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
但要用国内源,我现不能用-c这一段,直接用

conda install pytorch torchvision cudatoolkit=10.1

 

临时使用镜像源

清华镜像:

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

中国外国语大学镜像:

-c https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/

阿里源:

-c https://mirrors.aliyun.com/anaconda/pkgs/main/

conda镜像源:

查看有的默认源:

conda config --show-sources

删除默认源:

conda config --remove-key channels

永久设置镜像源

conda config --add channels 加镜像源地址

conda常用指令:

创建环境 :

conda create -n 环境名字 python=版本号

激活环境 :

conda activate 环境名字

退出环境 :

conda deactivate

安装包 :

pip install 包名

conda install 包名

删除包:

pip uninstall 包名

conda uninstall 包名

查看环境有那些包:

pip list

conda list

查看有那些环境:

conda info -e

删除环境:

conda remove -n test --all

pip镜像源:

永久设置镜像源:

pip config set global.index-url 加镜像源地址

临时使用镜像源:

在下载的包后加上下面的链接

清华源:

-i https://pypi.tuna.tsinghua.edu.cn/simple/

中科大源:

-i https://pypi.mirrors.ustc.edu.cn/simple/

阿里源:

-i https://mirrors.aliyun.com/pypi/simple/

豆瓣源:

-i https//pypi.doubanio.com/simple/

 

 

posted on 2020-12-14 18:32  lmqljt  阅读(345)  评论(0)    收藏  举报

导航