因为我是在root用户下安装的anaconda,所以创建环境要在root下执行。
下载
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.2.0-Linux-x86_64.sh
安装
sudo sh Anaconda3-5.2.0-Linux-x86_64.sh
制定安装目录
配置环境变量
添加“export PATH=/usr/local/anconda3/bin:$PATH“ 到/etc/profile,这样所有用户都可以使用Anaconda python3.7了。
上面的.bashrc在刚才安装时添加了如下内容:
# added by Anaconda3 5.3.0 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/usr/local/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/usr/local/anaconda3/etc/profile.d/conda.sh" ]; then
. "/usr/local/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/usr/local/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup~/.bashrc
# <<< conda init <<<
加载环境变量
source ~/.bashrc
换源
在.condarc文件后加一下语句
auto_activate_base: false
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/simpleitk
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
show_channel_urls: true
ssl_verify: false
report_errors: false
常用命令
序号功能命令备注
1查看conda 版本
conda —version,conda -V
2更新conda
conda update conda
3查看conda帮助(对初学者很有用的命令)
conda —help,conda -h
4新建虚拟环境conda create —name 多个包名用空格分开
5切换conda环境
conda activate env_name
6退出虚拟环境
conda deactivate
7列出所有虚拟环境
conda info —envs
conda info -e
conda env list
8复制环境conda create —name new_env_name —clone copied_env_name
9删除环境
conda remove —name env_name —all
10精确查找包conda search —full-name
11模糊查找包conda search
12获取当前环境中已安装的包信息conda list
13指定环境安装包conda install —name 指定版本:conda install —name
14在当前环境中安装包conda install
15pip安装pip install conda装不了的(或没有的)可用pip来安装
在VScode中配置环境
在扩展插件中安装:python