如何部署和恢复miniconda

1. 下载 Miniconda 安装包(适用于 Linux x86_64)
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
2. 安装 Miniconda
chmod +x Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

安装过程中会先查看协议、设置安装路径、修改环境变量,不想自定义直接默认即可:

Do you accept the license terms? [yes|no]
>>>
Please answer 'yes' or 'no':'
>>> yes

Miniconda3 will now be installed into this location:
/home/ubuntu/miniconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/ubuntu/miniconda3] >>>
PREFIX=/home/ubuntu/miniconda3
Unpacking payload ...

Installing base environment...


Downloading and Extracting Packages:
installation finished.
Do you wish to update your shell profile to automatically initialize conda?
This will activate conda on startup and change the command prompt when activated.
If you'd prefer that conda's base environment not be activated on startup,
   run the following command when conda is activated:

conda config --set auto_activate_base false

You can undo this by running `conda init --reverse $SHELL`? [yes|no]
[no] >>> no  # 这里输入no可以让用户进入系统后,自动激活python环境,你也可以输入yes,后续自己手动激活conda环境

3. 激活 conda 命令(安装完成后可能需要执行一次)
source ~/miniconda3/bin/activate
创建 Python 虚拟环境
conda create -n myenv python=3.10
手动激活环境
conda activate myenv
环境配置
# 导出
conda env export > myenv.yaml
# 导入
conda env create -f myenv.yaml
posted @ 2025-04-15 18:35  柠檬茶pro  阅读(180)  评论(0)    收藏  举报