环境:ubuntu 16.04
1.安装
- 下载页面。
- 下面将把Anaconda安装在/home/<yourname>/software/anaconda2目录下,而默认安装位置是/home/<yourname>/anaconda2。安装:bash AnacondaX-XXX.sh。点击Enter键查看许可证、输入yes同意协议、输入安装位置(可选):
Do you accept the license terms? [yes|no]
[no] >>> yes
Anaconda2 will now be installed into this location:
/home/<yourname>/anaconda2
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/<yourname>/anaconda2] >>> /home/<yourname>/software/anaconda2
PREFIX=/home/<yourname>/software/anaconda2
Unpacking payload ...
Extracting : ...
...
Preparing transaction: done
Executing transaction: \ WARNING conda.core.envs_manager:register_env(46): Unable to register environment. Path not writable or missing.
environment location: /home/omen/software/anaconda3
registry file: /home/omen/.conda/environments.txt
done
installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> yes
no change /home/omen/software/anaconda3/condabin/conda
no change /home/omen/software/anaconda3/bin/conda
no change /home/omen/software/anaconda3/bin/conda-env
no change /home/omen/software/anaconda3/bin/activate
no change /home/omen/software/anaconda3/bin/deactivate
no change /home/omen/software/anaconda3/etc/profile.d/conda.sh
no change /home/omen/software/anaconda3/etc/fish/conf.d/conda.fish
no change /home/omen/software/anaconda3/shell/condabin/Conda.psm1
no change /home/omen/software/anaconda3/shell/condabin/conda-hook.ps1
no change /home/omen/software/anaconda3/lib/python3.7/site-packages/xontrib/conda.xsh
no change /home/omen/software/anaconda3/etc/profile.d/conda.csh
modified /home/omen/.bashrc
==> For changes to take effect, close and re-open your current shell. <==
If you'd prefer that conda's base environment not be activated on startup,
set the auto_activate_base parameter to false:
conda config --set auto_activate_base false
Thank you for installing Anaconda3!
===========================================================================
Anaconda and JetBrains are working together to bring you Anaconda-powered
environments tightly integrated in the PyCharm IDE.
PyCharm for Anaconda is available at:
https://www.anaconda.com/pycharm
会在/home/<yourname>/.bashrc文件中追加:
# added by Anaconda2 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/home/<yourname>/software/anaconda2/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/home/<yourname>/software/anaconda2/etc/profile.d/conda.sh" ]; then
. "/home/<yourname>/software/anaconda2/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/home/<yourname>/software/anaconda2/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
这时/home/<yourname>/software/anaconda2/env是空的。
2.创建环境
创建python版本为2.7、名称为tf15(想在这个环境内安装tensorflow1.5)的环境:conda create -n tf15 python=2.7,-n也可以是-name。提示:
conda create -n tf15 python=2.7
## Package Plan ##
environment location: /home/<yourname>/software/anaconda2/envs/tf15
added / updated specs:
- python=2.7
The following NEW packages will be INSTALLED:
ca-certificates: 2018.03.07-0
...
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate tf15
#
# To deactivate an active environment, use
#
# $ conda deactivate
会在/home/<yourname>/software/anaconda2/envs下产生一个名为tf15的文件夹。
3.激活/关闭环境
如上面提示的那样,使用命令:conda activate tf15可激活tf15,使用conda deactivate可以关闭激活的环境。
4.查看所有虚拟环境
命令:conda env list。输出:
# conda environments:
#
base * /home/<yourname>/software/anaconda2
tf15 /home/<yourname>/software/anaconda2/envs/tf15
5.删除环境
命令:conda remove -n tf15 --all。这会删除/home/<yourname>/software/anaconda2/envs下名为tf15的文件夹。
6.查找/安装/删除包
pip可以安装一些conda无法安装的包;conda也可以安装一些pip无法安装的包。因此当使用一种命令无法安装包时,可以尝试用另一种命令。pip和conda的用法一样。注意使用pip还是pip3!
精确查找:
conda search --full-name <package_full_name>
模糊查找:
conda search <text>
在当前环境安装包:
conda install tensorflow-gpu==1.2.1
conda install cython
卸载包
conda remove tensorflow-gpu==1.2.1
conda remove --name tf121_27 tensorflow-gpu==1.2.1
8.获取当前环境中已安装的包信息
conda list
9.更改环境名称
#克隆环境
conda create --name secondEnv --clone firstEnv
#删除环境
conda remove --name firstEnv --all
10.终端总是显示(base)
conda config --set auto_activate_base False
[更多]