mamba icon indicating copy to clipboard operation
mamba copied to clipboard

[micromamba] `micromamba env export` does not show packages installed with `pip`

Open zacharyburnett opened this issue 3 years ago • 5 comments

I created an environment with micromamba:

micromamba create -n mamba_export_test

and then installed a package with pip:

micromamba activate mamba_export_test
pip install requests

However, when running micromamba env export, the packages installed with pip are not shown:

name: mamba_export_test
channels:
- https://repo.anaconda.com/pkgs/main
dependencies:
- python=3.10.6=hdfd78df_0
- pip=22.2.2=py310hecd8cb5_0
- xz=5.2.6=hca72f7f_0
- ncurses=6.3=hca72f7f_3
- readline=8.1.2=hca72f7f_1
- ca-certificates=2022.07.19=hecd8cb5_0
- zlib=1.2.12=h4dc903c_3
- libcxx=14.0.6=h9765a3e_0
- bzip2=1.0.8=h1de35cc_0
- wheel=0.37.1=pyhd3eb1b0_0
- tk=8.6.12=h5d9f67b_0
- libffi=3.3=hb1e8313_2
- tzdata=2022c=h04d1e81_0
- openssl=1.1.1q=hca72f7f_0
- certifi=2022.9.24=py310hecd8cb5_0
- sqlite=3.39.3=h707629a_0
- setuptools=63.4.1=py310hecd8cb5_0

In contrast, conda env export shows the pip packages:

name: /Users/zburnett/micromamba/envs/mamba_export_test
channels:
  - defaults
dependencies:
  - bzip2=1.0.8=h1de35cc_0
  - ca-certificates=2022.07.19=hecd8cb5_0
  - certifi=2022.9.24=py310hecd8cb5_0
  - libcxx=14.0.6=h9765a3e_0
  - libffi=3.3=hb1e8313_2
  - ncurses=6.3=hca72f7f_3
  - openssl=1.1.1q=hca72f7f_0
  - pip=22.2.2=py310hecd8cb5_0
  - python=3.10.6=hdfd78df_0
  - readline=8.1.2=hca72f7f_1
  - setuptools=63.4.1=py310hecd8cb5_0
  - sqlite=3.39.3=h707629a_0
  - tk=8.6.12=h5d9f67b_0
  - tzdata=2022c=h04d1e81_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.2.6=hca72f7f_0
  - zlib=1.2.12=h4dc903c_3
  - pip:
    - charset-normalizer==2.1.1
    - idna==3.4
    - requests==2.28.1
    - urllib3==1.26.12
prefix: /Users/zburnett/micromamba/envs/mamba_export_test

closed by #2104 closed by #3565

zacharyburnett avatar Oct 11 '22 13:10 zacharyburnett

Um... how is this not a priority bug? Am I using (micro)mamba wrong?

jmakov avatar Dec 24 '22 13:12 jmakov

list suffer from the same issue.

(prep) sik@dory:/tmp/tmp.OFUuqwduLJ$ micromamba env create -n foo -c conda-forge -q -y python pip
(prep) sik@dory:/tmp/tmp.OFUuqwduLJ$ micromamba activate foo
(foo) sik@dory:/tmp/tmp.OFUuqwduLJ$ pip install requests
Collecting requests
  Using cached requests-2.28.2-py3-none-any.whl (62 kB)
Collecting charset-normalizer<4,>=2
  Downloading charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (197 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 197.3/197.3 kB 3.0 MB/s eta 0:00:00
Collecting idna<4,>=2.5
  Using cached idna-3.4-py3-none-any.whl (61 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.14-py2.py3-none-any.whl (140 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
Successfully installed certifi-2022.12.7 charset-normalizer-3.1.0 idna-3.4 requests-2.28.2 urllib3-1.26.14
(foo) sik@dory:/tmp/tmp.OFUuqwduLJ$ micromamba list
List of packages in environment: "/home/sik/opt/conda/envs/foo"

  Name              Version    Build               Channel    
────────────────────────────────────────────────────────────────
  _libgcc_mutex     0.1        conda_forge         conda-forge
  _openmp_mutex     4.5        2_gnu               conda-forge
  bzip2             1.0.8      h7f98852_4          conda-forge
  ca-certificates   2022.12.7  ha878542_0          conda-forge
  ld_impl_linux-64  2.40       h41732ed_0          conda-forge
  libffi            3.4.2      h7f98852_5          conda-forge
  libgcc-ng         12.2.0     h65d4601_19         conda-forge
  libgomp           12.2.0     h65d4601_19         conda-forge
  libnsl            2.0.0      h7f98852_0          conda-forge
  libsqlite         3.40.0     h753d276_0          conda-forge
  libuuid           2.32.1     h7f98852_1000       conda-forge
  libzlib           1.2.13     h166bdaf_4          conda-forge
  ncurses           6.3        h27087fc_1          conda-forge
  openssl           3.0.8      h0b41bf4_0          conda-forge
  pip               23.0.1     pyhd8ed1ab_0        conda-forge
  python            3.11.0     he550d4f_1_cpython  conda-forge
  readline          8.1.2      h0f457ee_0          conda-forge
  setuptools        67.5.1     pyhd8ed1ab_0        conda-forge
  tk                8.6.12     h27826a3_0          conda-forge
  tzdata            2022g      h191b570_0          conda-forge
  wheel             0.38.4     pyhd8ed1ab_0        conda-forge
  xz                5.2.6      h166bdaf_0          conda-forge
(foo) sik@dory:/tmp/tmp.OFUuqwduLJ$ pip list
Package            Version
------------------ ---------
certifi            2022.12.7
charset-normalizer 3.1.0
idna               3.4
pip                23.0.1
requests           2.28.2
setuptools         67.5.1
urllib3            1.26.14
wheel              0.38.4

massich avatar Mar 08 '23 13:03 massich

Are there any updates regarding this bug?

zN3utr4l avatar May 09 '23 07:05 zN3utr4l

I think this is the latest state https://github.com/mamba-org/mamba/pull/2104

jonashaag avatar May 09 '23 10:05 jonashaag

for anyone following this issue who is short on time, here's a simple convenience script that appends pip freeze to mamba env export:

import argparse
import yaml
from pathlib import Path

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        prog="mamba_export_pip",
        description="appends the output of `pip freeze` to the end of an existing Mamba YAML exported with `mamba env export`, in the corresponding `pip` section",
        epilog="this script replicates the functionality of https://github.com/mamba-org/mamba/pull/2104, and will be obsolete when it is merged",
    )

    parser.add_argument("mamba_export_filename")
    parser.add_argument("pip_freeze_filename")

    arguments = parser.parse_args()

    mamba_export_filename = Path(arguments.mamba_export_filename)
    pip_freeze_filename = Path(arguments.pip_freeze_filename)

    with open(mamba_export_filename) as mamba_export_file:
        mamba_export = yaml.safe_load(mamba_export_file)

    with open(pip_freeze_filename) as pip_freeze_file:
        pip_freeze = pip_freeze_file.readlines()

    pip_freeze = [
        requirement.strip()
        for requirement in pip_freeze
        if " @ file" not in requirement
    ]

    mamba_export["dependencies"].append({"pip": pip_freeze})

    print(yaml.dump(mamba_export))

zacharyburnett avatar Jun 17 '24 15:06 zacharyburnett