Contents

tool:conda

本文采用知识共享署名 4.0 国际许可协议进行许可,转载时请注明原文链接,图片在使用时请保留全部内容,可适当缩放并在引用处附上图片所在的文章链接。

介绍

Conda 是一个开源的软件包管理系统和环境管理系统,用于安装多个版本的软件包及其依赖关系,并在它们之间轻松切换。

Conda 是为 Python 程序创建的,适用于 Linux,OS X 和Windows,也可以打包和分发其他软件 。 是最流行的 Python 环境管理工具。

安装

conda 是包含在 Anaconda 里的。我们安装了Anaconda就可以使用Conda了。

下载

清华源

1
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
1
2
3
4
5
## 下载
$ wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh
## 查看
$ ls
Anaconda3-2021.05-Linux-x86_64.sh

命令

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 判断版本
conda -V

# 如果要更新版本
conda update conda

# 列出当前环境
conda info --envs

# 创建环境
conda create --name [name] [dependent package list]

# 例如:
conda create --name snowflakes biopython

# 指定了python版本
conda create --name bunnies python=3.5 astroid babel

# 从其他环境拷贝到新的环境
conda create --name flowers --clone snowflakes
conda create --name flet --clone base

# 删除指定环境
conda remove --name flowers --all

# 激活环境
conda activate test

# 推出环境
conda deactivate

JupyterLab写C++

新建文件,命名为cling.yml

1
touch cling.yml

将以下内容复制黏贴到cling.yml中:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
name: cling
channels:
    - conda-forge
    - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    - defaults
dependencies:
    - python=3
    - pip=19.2.1
    - jupyter
    - notebook
    - xeus-cling=0.7.1
  • 通过yml文件创建虚拟环境
1
conda env create -f cling.yml