加载中...
不想等待可以点我关掉

命令

环境管理

  • 创建环境:conda create --name(-n) myenv python=3.10
  • 激活环境:conda activate myenv
  • 退出环境:conda deactivate
  • 查看所有环境: conda env listconda info --envs
  • 删除环境: conda remove --name myenv --all
  • 导出环境配置 (分享给他人):conda env export > environment.yml
  • 从配置文件创建环境:conda env create -f environment.yml

包管理

在激活的环境中安装、更新或删除具体的工具库。

操作命令示例备注
安装包conda install numpy也可以指定版本 numpy=1.24
删除包conda remove numpy从当前环境中移除
更新包conda update numpy更新到兼容的最新版本
查看已安装conda list列出当前环境所有包
搜索包conda search pandas检查可用版本

渠道管理

配置镜像源

  • 添加新渠道:conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  • 设置安装时显示来源:conda config --set show_channel_urls yes
  • 查看当前配置:conda config --show-sources

清理与维护

  • 清理缓存 (索引、包、未使用过的包):conda clean --all
  • 检查 Conda 版本:conda --version
  • 更新 Conda 自身:conda update conda

报错类

空壳环境

在创建环境时没有显式指定python版本号时,不会安装python,系统会按照顺序找到base环境下的python和pip

附:powershell查询环境变量

1
2
3
4
5
6
7
8
9
10
11
12
(moonraker-reminder) PS G:\Project\moonraker-reminder> $env:Path.Split(';') | Select-String "miniforge3"

D:\ProgramData\miniforge3\envs\moonraker-reminder
D:\ProgramData\miniforge3\envs\moonraker-reminder\Library\mingw-w64\bin
D:\ProgramData\miniforge3\envs\moonraker-reminder\Library\usr\bin
D:\ProgramData\miniforge3\envs\moonraker-reminder\Library\bin
D:\ProgramData\miniforge3\envs\moonraker-reminder\Scripts
D:\ProgramData\miniforge3\envs\moonraker-reminder\bin
D:\ProgramData\miniforge3\condabin
D:\ProgramData\miniforge3
D:\ProgramData\miniforge3\Scripts
D:\ProgramData\miniforge3\Library\bin