conda创建新环境
如果只是用的话,用【创建】和【激活】的命令足够了~
第一步:创建
conda create --name yourEnv python=2.7
–name:也可以缩写为 【-n】,【yourEnv】是新创建的虚拟环境的名字,创建完,可以装anaconda的目录下找到envs/yourEnv 目录
python=2.7:是python的版本号。也可以指定为【python=3.6】,若未指定,默认为是装anaconda时python的版本.
若想要在创建环境同时安装python的一些包:
conda create -n yourEnv python=3.6 numpy pandas
若想在别人虚拟环境的基础上创建自己的环境:
conda create --name --clone
第二步:激活
windows
activate yourEnv
linux/mac
source activate yourEnv
tips:
linux用户需要进入到anaconda/envs目录下激活需要的环境,或者通过命令source active /home/yourName/anaconda3/envs/yourEnv激活需要的环境;
上面激活的方式进入目录太复杂 or 命令太长了,可以通过设置全局变量或者用linux的别名alias设置。
第一种方式,将需要激活的路径下的bin文件添加到全局环境变量中如将/home/yourName/anaconda3/envs/yourEnv/bin添加到~/.bash_profile中。
第二种方式,通过vim ~/.bash_profile,向里面添加alias activeEnv=‘source activate /home/yourName/anaconda3/envs/yourEnv’,source ~/.bash_profile之后可以直接在命令行输入activeEnv激活相应环境
建议第二种,并建议看下linux的alias,非常好用
windows用户环境变量中添加(改成自己的路径):
D:\Anaconda3
D:\Anaconda3\Scripts
D:\Anaconda3\Library\bin
第三步:查看活跃的环境
conda info --envs:输出中带有【*】号的的就是当前所处的环境
conda一些命令 conda list: 看这个环境下安装的包和版本 conda install numpy scikit-learn:
安装numpy sklearn包 conda env remove -n yourEnv: 删除你的环境 conda env list:
查看所有的环境
anaconda下载
比起官网,建议从清华开源镜像站下载相应版本
wget
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh
bash Anaconda3-5.3.1-Linux-x86_64.sh
清华镜像源配置
清华官方说明:Anaconda 镜像使用帮助,主要概括为向 .condarc填充以下内容:
channels:
- defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
- 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/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud