1.linux安装
conda可以创建多种语言环境,支持的语言有,可以创建多种复杂环境,如果只需要python环境,pycharm自带的应该可以满足需求
Python, R, Ruby, Lua, Scala, Java, JavaScript, C/C++, FORTRAN。
官网下载比较慢,使用清华大学开源软件镜像站下载会比较快
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
下载完成后会得到 Anaconda3-2020.11-Linux-x86_64.sh 文件
下载完成后在命令行运行此文件
./Anaconda3-2020.11-Linux-x86_64.sh
会提示需要阅读许可证协议,按回车继续,阅读完成后输入yes,再回车后继续安装
Last updated September 28, 2020
Do you accept the license terms? [yes|no]
[no] >>> yes
Anaconda3 will now be installed into this location:
/home/mchen/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/home/mchen/anaconda3] >>>
最后会提示你是否初始化,输入yes
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> yes
安装完成后,重新打开命令行,检查是否安装成功
(base) mchen@ubuntu:~$ conda --version
conda 4.9.2
2.基本使用
创建虚拟环境
conda create -n name python=version
激活环境
#
# To activate this environment, use
#
$ conda activate env_name
退出环境
# To deactivate an active environment, use
$ conda deactivate
下载第三方库
conda install model-name
查看当前环境信息
conda info
输出
active environment : ITS_Test
active env location : /home/mchen/anaconda3/envs/ITS_Test
shell level : 2
user config file : /home/mchen/.condarc
populated config files :
conda version : 4.9.2
conda-build version : 3.20.5
python version : 3.8.5.final.0
virtual packages : __glibc=2.31=0
__unix=0=0
__archspec=1=x86_64
base environment : /home/mchen/anaconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/mchen/anaconda3/pkgs
/home/mchen/.conda/pkgs
envs directories : /home/mchen/anaconda3/envs
/home/mchen/.conda/envs
platform : linux-64
user-agent : conda/4.9.2 requests/2.24.0 CPython/3.8.5 Linux/5.4.0-56-generic ubuntu/20.04.1 glibc/2.31
UID:GID : 1000:1000
netrc file : None
offline mode : False
查看已经创建的虚拟环境信息
conda info -e
or
conda env list
输出:
# conda environments:
#
base /home/mchen/anaconda3
ITS_Test * /home/mchen/anaconda3/envs/ITS_Test
删除python包
conda remove package_name
or
pip uninstall package_name
安装python包
conda install name
or
pip install name
导出环境
# 需要在将要导出的虚拟环境内使用
conda env export > file_name.yaml
导入环境
# 如果不指定新的名称,将使用导出的名称
conda env create -f file_name.yaml -n new_env_name
删除环境
conda remove -n env_name --all
or
conda env remove -n env_name