轻松拿捏!windows系统上安装Mamba
windows系统上安装Mamba
一、简介
micromamba
是一个快速、小巧的包管理和环境管理工具,专为数据科学、机器学习和开发人员设计,用来替代 conda
或 mamba
。它主要用于管理 Python 包和创建隔离的工作环境,确保每个项目可以独立运行,不会受其他项目的依赖冲突影响。
什么是 micromamba?
- 轻量级:micromamba 体积小,不像 conda 那样需要安装一个庞大的 Anaconda 或 Miniconda。
- 速度快:使用
C++
编写,安装包和创建环境的速度比 conda 更快。 - 跨平台:支持 Windows、Linux 和 macOS,适合各种操作系统。
micromamba 的基本用途
- 包管理:下载和安装 Python 包(例如
NumPy
、Pandas
、TensorFlow
等),还能管理 R 和其他语言的包。 - 环境管理:创建独立的虚拟环境,每个环境可以有不同的 Python 版本和包,不会相互干扰。
为什么选择 micromamba?
- 更高效:micromamba 不仅安装和更新包更快,还减少了系统资源占用。
- 便携性:因为是一个单独的可执行文件,只需下载
micromamba.exe
即可使用,不需要额外安装Anaconda
。 - 适合服务器环境:在服务器或无管理员权限的系统中也可以使用,适合在云环境中快速搭建环境。
二、window安装实操
① 打开cmd,输入以下代码:
powershell
② 下载相应压缩包(可选:cd到指定路径再下载):
Invoke-WebRequest -URI https://micro.mamba.pm/api/micromamba/win-64/latest -OutFile micromamba.tar.bz2
tar xf micromamba.tar.bz2
Move-Item -Force Library\bin\micromamba.exe micromamba.exe
③ 设置安装路径,小编设置的是在C:\micromambaenv
:
$Env:MAMBA_ROOT_PREFIX="C:\micromambaenv"
④ 执行安装。运行以下命令以初始化 micromamba,让其在 PowerShell 中生效:
.\micromamba.exe shell hook -s powershell | Out-String | Invoke-Expression
.\micromamba.exe shell init -s powershell C:\micromambaenv
⑤ 最后运行以下代码检查一下有没有安装成功:
micromamba
输出如下:
Version: 2.0.2
Usage: C:\Users\30768\micromamba.exe [OPTIONS] [SUBCOMMAND]
Options:
-h,--help Print this help message and exit
--version
Configuration options:
--rc-file TEXT ... Paths to the configuration files to use
--no-rc Disable the use of configuration files
--no-env Disable the use of environment variables
Global options:
-v,--verbose Set verbosity (higher verbosity with multiple -v, e.g. -vvv)
--log-level ENUM:value in {critical->5,debug->1,error->4,info->2,off->6,trace->0,warning->3} OR {5,1,4,2,6,0,3}
Set the log level
-q,--quiet Set quiet mode (print less output)
-y,--yes Automatically answer yes on prompted questions
--json Report all output as json
--offline Force use cached repodata
--dry-run Only display what would have been done
--download-only Only download and extract packages, do not link them into environment.
--experimental Enable experimental features
Prefix options:
-r,--root-prefix TEXT Path to the root prefix
-p,--prefix TEXT Path to the target prefix
--relocate-prefix TEXT Path to the relocation prefix
-n,--name TEXT Name of the target prefix
Subcommands:
shell Generate shell init scripts
create Create new environment
install Install packages in active environment
update Update packages in active environment
self-update Update micromamba
repoquery Find and analyze packages in active environment or channels
remove Remove packages from active environment
list List packages in active environment
package Extract a package or bundle files into an archive
clean Clean package cache
config Configuration of micromamba
info Information about micromamba
constructor Commands to support using micromamba in constructor
env List environments
activate Activate an environment
run Run an executable in an environment
ps Show, inspect or kill running processes
auth Login or logout of a given host
search Find packages in active environment or channels
This is equivalent to `repoquery search` command
分享结束