新一代python包管理软件mamba的使用

 更新时间:2025年06月29日 10:26:29   作者:skywalk8163  
新一代python的包管理软件mambaMamba 是一个高性能的跨平台包管理器,用于替代和扩展 Conda,采用 C++ 重构,实现多线程的仓库数据和包文件并行下载,大幅提升依赖解析速度

Mamba 是一个高性能的跨平台包管理器,用于替代和扩展 Conda,采用 C++ 重构,实现多线程的仓库数据和包文件并行下载,大幅提升依赖解析速度。

官网repo:mamba-org/micromamba-releases: Micromamba executables mirrored from conda-forge as Github releases

下载安装

直接下载最新的可执行版本:

直接到发布页面下载即可,比如当前最新版本是2.3.0版本,下载linux版:

wget https://github.com/mamba-org/micromamba-releases/releases/download/2.3.0-1/micromamba-linux-64

拿到文件后,chmod 755 给个执行权限,即可执行:

root@j7ba948ec6f7425190a818336fcd0045-task0-0:/tmp/code# chmod 755 micromamba-linux-64 
root@j7ba948ec6f7425190a818336fcd0045-task0-0:/tmp/code# ./micromamba-linux-64 
Version: 2.3.0 

./micromamba-linux-64 [OPTIONS] [SUBCOMMAND]

OPTIONS:
  -h,     --help              Print this help message and exit 
          --version           

这时候mamab就可以直接用了。

使用安装脚本安装

直接下载repo源代码,用里面的安装脚本安装即可。

git clone https://github.com/mamba-org/micromamba-releases

然后执行里面的install.sh 脚本即可。

也可以直接使用wget或者curl获得安装脚本,比如: 

wget https://raw.githubusercontent.com/mamba-org/micromamba-releases/refs/heads/main/install.sh

curl https://raw.githubusercontent.com/mamba-org/micromamba-releases/refs/heads/main/install.sh

下载并改名:

curl -L https://raw.githubusercontent.com/mamba-org/micromamba-releases/refs/heads/main/install.sh -o micromamba.sh

实在没办法,还可以直接把下面代码存盘,存为install.sh ,然后执行即可安装mamba:

#!/bin/sh

set -eu

# Detect the shell from which the script was called
parent=$(ps -o comm $PPID |tail -1)
parent=${parent#-}  # remove the leading dash that login shells have
case "$parent" in
  # shells supported by `micromamba shell init`
  bash|fish|xonsh|zsh)
    shell=$parent
    ;;
  *)
    # use the login shell (basename of $SHELL) as a fallback
    shell=${SHELL##*/}
    ;;
esac

# Parsing arguments
if [ -t 0 ] ; then
  printf "Micromamba binary folder? [~/.local/bin] "
  read BIN_FOLDER
  printf "Init shell ($shell)? [Y/n] "
  read INIT_YES
  printf "Configure conda-forge? [Y/n] "
  read CONDA_FORGE_YES
fi

# Fallbacks
BIN_FOLDER="${BIN_FOLDER:-${HOME}/.local/bin}"
INIT_YES="${INIT_YES:-yes}"
CONDA_FORGE_YES="${CONDA_FORGE_YES:-yes}"

# Prefix location is relevant only if we want to call `micromamba shell init`
case "$INIT_YES" in
  y|Y|yes)
    if [ -t 0 ]; then
      printf "Prefix location? [~/micromamba] "
      read PREFIX_LOCATION
    fi
    ;;
esac
PREFIX_LOCATION="${PREFIX_LOCATION:-${HOME}/micromamba}"

# Computing artifact location
case "$(uname)" in
  Linux)
    PLATFORM="linux" ;;
  Darwin)
    PLATFORM="osx" ;;
  *NT*)
    PLATFORM="win" ;;
esac

ARCH="$(uname -m)"
case "$ARCH" in
  aarch64|ppc64le|arm64)
      ;;  # pass
  *)
    ARCH="64" ;;
esac

case "$PLATFORM-$ARCH" in
  linux-aarch64|linux-ppc64le|linux-64|osx-arm64|osx-64|win-64)
      ;;  # pass
  *)
    echo "Failed to detect your OS" >&2
    exit 1
    ;;
esac

if [ "${VERSION:-}" = "" ]; then
  RELEASE_URL="https://github.com/mamba-org/micromamba-releases/releases/latest/download/micromamba-${PLATFORM}-${ARCH}"
else
  RELEASE_URL="https://github.com/mamba-org/micromamba-releases/releases/download/${VERSION}/micromamba-${PLATFORM}-${ARCH}"
fi


# Downloading artifact
mkdir -p "${BIN_FOLDER}"
if hash curl >/dev/null 2>&1; then
  curl "${RELEASE_URL}" -o "${BIN_FOLDER}/micromamba" -fsSL --compressed ${CURL_OPTS:-}
elif hash wget >/dev/null 2>&1; then
  wget ${WGET_OPTS:-} -qO "${BIN_FOLDER}/micromamba" "${RELEASE_URL}"
else
  echo "Neither curl nor wget was found" >&2
  exit 1
fi
chmod +x "${BIN_FOLDER}/micromamba"


# Initializing shell
case "$INIT_YES" in
  y|Y|yes)
    case $("${BIN_FOLDER}/micromamba" --version) in
      1.*|0.*)
        shell_arg=-s
        prefix_arg=-p
        ;;
      *)
        shell_arg=--shell
        prefix_arg=--root-prefix
        ;;
    esac
    "${BIN_FOLDER}/micromamba" shell init $shell_arg "$shell" $prefix_arg "$PREFIX_LOCATION"

    echo "Please restart your shell to activate micromamba or run the following:\n"
    echo "  source ~/.bashrc (or ~/.zshrc, ~/.xonshrc, ~/.config/fish/config.fish, ...)"
    ;;
  *)
    echo "You can initialize your shell later by running:"
    echo "  micromamba shell init"
    ;;
esac


# Initializing conda-forge
case "$CONDA_FORGE_YES" in
  y|Y|yes)
    "${BIN_FOLDER}/micromamba" config append channels conda-forge
    "${BIN_FOLDER}/micromamba" config append channels nodefaults
    "${BIN_FOLDER}/micromamba" config set channel_priority strict
    ;;
esac

开始使用mamba

比如前面,我们已经下载了minimamba文件,并chmod 755 添加了执行权限,就可以直接开始执行了:

创建一个python3.10的虚拟环境

./micromamba-linux-64 create -n paddle python=3.10

感觉速度确实挺快的,输出

Transaction finished

To activate this environment, use:

    micromamba-linux-64 activate paddle

Or to execute a single command in this environment, use:

    micromamba-linux-64 run -n paddle mycommand

但是后面激活出了点问题,简单来说就是没激活成功

 ./micromamba-linux-64 activate paddle

'micromamba-linux-64' is running as a subprocess and can't modify the parent shell.
Thus you must initialize your shell before using activate and deactivate.

To initialize the current bash shell, run:
    $ eval "$(micromamba-linux-64 shell hook --shell bash)"
and then activate or deactivate with:
    $ micromamba-linux-64 activate
To automatically initialize all future (bash) shells, run:
    $ micromamba-linux-64 shell init --shell bash --root-prefix=~/.local/share/mamba
If your shell was already initialized, reinitialize your shell with:
    $ micromamba-linux-64 shell reinit --shell bash
Otherwise, this may be an issue. In the meantime you can run commands. See:
    $ micromamba-linux-64 run --help

Supported shells are {bash, zsh, csh, posix, xonsh, cmd.exe, powershell, fish, nu}.
critical libmamba Shell not initialized

 但是用mamba激活成功了:

root@j7ba948ec6f7425190a818336fcd0045-task0-0:/tmp/code# mamba activate paddle

0 examples ran in 0.0009 seconds
root@j7ba948ec6f7425190a818336fcd0045-task0-0:/tmp/code# python
Python 3.10.11 (main, Sep 12 2023, 07:11:29) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

现在我找不到虚拟环境的位置 .好吧,这个0 examples ran in 0.0009 seconds 

好像也不算运行成功啊!

安装飞桨

mamba好像没装成

pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple 

最后是这个完成的:

python -m pip install paddlepaddle==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/

测试:

root@j7ba948ec6f7425190a818336fcd0045-task0-0:/tmp/code# python 
Python 3.10.11 (main, Sep 12 2023, 07:11:29) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
import >>> import paddle
/usr/local/lib/python3.10/site-packages/paddle/utils/cpp_extension/extension_utils.py:711: UserWarning: No ccache found. Please be aware that recompiling all source files may be required. You can download and install ccache from: https://github.com/ccache/ccache/blob/master/doc/INSTALL.md
  warnings.warn(warning_message)
>>> x= paddle.to_tensor((1,2))
>>> y = x+1
>>> y
Tensor(shape=[2], dtype=int64, place=Place(cpu), stop_gradient=True,
       [2, 3])
>>> paddle.utils.run_check()
Running verify PaddlePaddle program ... 
I0621 15:01:31.758841   374 pir_interpreter.cc:1541] New Executor is Running ...
I0621 15:01:31.759274   374 pir_interpreter.cc:1564] pir interpreter is running by multi-thread mode ...
PaddlePaddle works well on 1 CPU.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.

其它安装方法安装飞桨

老的安装方法是成功的

python -m pip install paddlepaddle==3.0.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/

./micromamba-linux-64  create -n paddle python=3.10

使用包管理器mamba安装torch

mamba create -n torchmd python=3.10
mamba activate torchmd
mamba install pytorch python=3.10 -c conda-forge
mamba install moleculekit parmed jupyter -c acellera -c conda-forge # For running the examples
pip install torchmd

mamba create -n torchmd
mamba activate torchmd
mamba install pytorch python=3.10 -c conda-forge
mamba install moleculekit parmed jupyter -c acellera -c conda-forge # For running the examples
pip install torchmd

mamba create -n torchmd
mamba activate torchmd
mamba install paddlepaddle python=3.10 -c conda-forge
mamba install moleculekit parmed jupyter -c acellera -c conda-forge # For running the examples
pip install torchmd

效果并不太好,就先到这里吧

到此这篇关于新一代python包管理软件mamba的使用的文章就介绍到这了,更多相关python包管理软件mamba内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Python中Requests库的实现示例

    Python中Requests库的实现示例

    Requests是Python生态中最广泛使用的HTTP客户端库,本文主要介绍了Python中Requests库的实现示例,具有一定的参考价值,感兴趣的可以了解一下
    2025-05-05
  • python交易记录链的实现过程详解

    python交易记录链的实现过程详解

    这篇文章主要介绍了python交易记录链的实现过程详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2019-07-07
  • Python之reload流程实例代码解析

    Python之reload流程实例代码解析

    这篇文章主要介绍了Python之reload流程实例代码解析,分享了相关代码示例,小编觉得还是挺不错的,具有一定借鉴价值,需要的朋友可以参考下
    2018-01-01
  • 详解Python中namedtuple的使用

    详解Python中namedtuple的使用

    这篇文章主要介绍了Python中namedtuple的使用,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2020-04-04
  • OFD格式文件及如何适应Python将PDF转换为OFD格式文件

    OFD格式文件及如何适应Python将PDF转换为OFD格式文件

    OFD是中国自主研发的一种固定版式文档格式,主要用于电子公文、档案管理等领域,这篇文章主要介绍了OFD格式文件及如何适应Python将PDF转换为OFD格式文件的相关资料,文中通过代码介绍的非常详细,需要的朋友可以参考下
    2025-11-11
  • Python3网络爬虫开发实战之极验滑动验证码的识别

    Python3网络爬虫开发实战之极验滑动验证码的识别

    本节我们的目标是用程序来识别并通过极验验证码的验证,其步骤有分析识别思路、识别缺口位置、生成滑块拖动路径,最后模拟实现滑块拼合通过验证。需要的朋友可以参考下
    2019-08-08
  • 利用python绘制动态圣诞下雪图

    利用python绘制动态圣诞下雪图

    圣诞节快到了,给你最爱的人送上一颗python动态圣诞下雪图吧,所以今天小编给大家介绍了如何利用python绘制动态圣诞下雪图,文中有详细的代码示例,需要的朋友可以参考下
    2023-12-12
  • Python实现读取文件的方法总结

    Python实现读取文件的方法总结

    这篇文章主要为大家详细介绍了Python中实现读取文件效果的几种方法总结,文中的示例代码讲解详细,感兴趣的小伙伴可以了解一下
    2022-09-09
  • json跨域调用python的方法详解

    json跨域调用python的方法详解

    这篇文章主要介绍了json跨域调用python的方法,结合实例形式分析了基于ajax的json调用及Python后台处理技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2017-01-01
  • Python 字典dict使用介绍

    Python 字典dict使用介绍

    这篇文章主要介绍了Python 字典dict使用介绍,需要的朋友可以参考下
    2014-11-11

最新评论