Anaconda installation and configuration of domestic mirror source (pip & conda), conda environment creation and migration

download link

Download the Tsinghua Mirror from the official website

Install and enter the base environment

windows

Browser download

Run directly, Anaconda-...-Windows-*.exe
search Anacondain the lower left corner , open the dos interface of Anaconda, and automatically enter the base environment

linux

Download,
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2020.11-Linux-x86_64.sh
install
bash Anaconda3-2020.11-Linux-x86_64.sh
, select the automatic configuration environment yes
, activate the environment after installation
source ~/.bashrc

After entering the base environment, the left side of the command line will display(base)

Configure domestic mirror source

http://mirrors.aliyun.com/pypi/simple/ //阿里
https://pypi.tuna.tsinghua.edu.cn/simple/ //清华
http://pypi.douban.com/ //豆瓣
http://pypi.hustunique.com/ //华中理工大学
http://pypi.sdutlinux.org/ //山东理工大学
http://pypi.mirrors.ustc.edu.cn/ //中国科学技术大学

pip

mkdir ~/.pip
vim ~/.pip/pip.conf

Configure the file as a domestic mirror source (such as Douban) and modify the maximum waiting time

[global]
index-url = http://pypi.douban.com/simple
timeout=60000
[install]
trusted-host = pypi.douban.com

conda

Add mirror source
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
Delete mirror source
conda config --remove-key channels
View mirror source
conda config --show-sources
Show channel address
conda config --set show_channel_urls yes

Modify the configuration file directly

vim ~/.condarc

channels:
 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
 - defaults
show_channel_urls: true

Among them defaultsis the default foreign source

Create a sandbox

conda create -n name python=3.8#Sandbox name, python version
conda activate nameactivation environment

Environment transplant

Can be copied inside the same computer or copied to other computers

Networked environment copy

First activate the environment that needs to be copied, and copy the environment to the yamlfile (the file name can be modified at will)

conda activate [env-name]
 conda env export > env.yaml

yamlReproduce the environment according to the document

 conda env create -f env.yaml

offline environment copy

Detailed tutorial·Portal

Enter the */anaconda3/envs/directory and package the environment to be copied

tar cvf envirement.tar envirement

envirement.tarFiles are copied to the target computer */anaconda3/envs/directory through http, ssh, etc. , and unpacked

rsync -rzP */envirement.tar ~/anaconda3/envs
tar xvf envirement.tar

* : path of envirement.tar
Finally, modify the conda environment configuration file ~/.conda/envirement.txtand add the copied environment directory at the end
vim ~/.conda/envirement.txt

/root/anaconda3
/root/anaconda3/envs/envirement

Guess you like

Origin blog.csdn.net/qq_38832757/article/details/112878865