Miniforge

社区发行,是anaconda的轻量化,完全开源,首推用这种方式开启python,地址。有好几种不同的版本,推荐下载mambaforge(用manba代替了conda)。

下载安装完毕后,配置环境变量:

  1. C:_Code\mambaforge —— (Python MambaPython)
  2. C:_Code\mambaforge\Scripts —— (Mamba&Conda Scripts MambaScript)

配置完成后,cmd输入python检测。(windows下会出现输入python后打开应用商店的情况,这时候进入“应用执行别名”,把python相关的“应用安装程序”关掉即可)

配置文件

配置文件为~.condarc,打开配置文件,进行编辑。因为是国内,所以需要配置镜像。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- 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
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
show_channel_urls: true
ssl_verify: false

使用

和conda的用法一样,用“mamba”命令替代“conda”。mamba命令不起作用的话,就用conda。

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
31
32
33
34
35
36
37
# 查看版本
mamba --version

# 查看详情
mamba info

# 升级
mamba update mamba

# 创建环境
mamba create -n <env_name>

# 创建指定版本的环境
mamba create -n [env_name] python=3.9.12

# 用当前目录下的配置文件创建新的运行环境
mamba env create -f environment.yaml

# 启用环境(启用环境、关闭环境推荐用conda命令)
conda activate <env_name>

# 关闭环境
conda deactivate

# 查看所有环境
conda env list

# 删除环境
mamba remove --name <env_name> --all

# 安装pip
conda install pip

# 重命名环境。通过复制来完成
mamba create -n name2 --clone name
# 删除环境
mamba remove -n <name> --all