pythonpipmambamicromamba

How to check if packages are as in "micromamba list" after pip broke it?


I tried to install a package (hyperfit) which is only availabe via PyPI. Given that I have my whole environment set up with micromamba, I installed all the dependency, and tried to install the package. Well, the thing is, pip broke my environment, silently, without asking me. Specifically, it uninstalled the latest numpy I had and reverted it to old version without letting me know. (See snippet 1.)

The problem is, when I ran micromamba list, the version didn't seem to be affected by the pip, as shown by the example below.

numpy                          2.0.2                py312h58c1407_0          conda-forge

When I checked with python, it did import 1.2.6, not 2.0.2, which I had to force-reinstall the numpy.

The thing is, I had similar experience with pip before. I don't know how many packages were altered unnoticed. How do I check if all packages are as shown in micromamba list, or at the very least, force micromamba to reinstall all the packages?

Snippet 1.

❯ pip install hyperfit                                                                                                                            2024-11-06 18:32:20 CST
Collecting hyperfit
  Using cached hyperfit-0.1.7-py3-none-any.whl.metadata (1.5 kB)
Requirement already satisfied: numpy>=1.20.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from hyperfit) (2.0.2)
Requirement already satisfied: scipy>=1.6.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from hyperfit) (1.14.1)
Requirement already satisfied: zeus-mcmc>=2.3.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from hyperfit) (2.5.4)
Requirement already satisfied: pandas>=1.2.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from hyperfit) (2.2.2)
Requirement already satisfied: emcee>=3.0.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from hyperfit) (3.1.6)
Requirement already satisfied: snowline>=0.5.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from hyperfit) (0.6.3)
Requirement already satisfied: python-dateutil>=2.8.2 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from pandas>=1.2.0->hyperfit) (2.9.0)
Requirement already satisfied: pytz>=2020.1 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from pandas>=1.2.0->hyperfit) (2024.2)
Requirement already satisfied: tzdata>=2022.7 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from pandas>=1.2.0->hyperfit) (2024.2)
Requirement already satisfied: pypmc in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from snowline>=0.5.0->hyperfit) (1.2.2)
Requirement already satisfied: iminuit in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from snowline>=0.5.0->hyperfit) (2.30.1)
Requirement already satisfied: tqdm in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from zeus-mcmc>=2.3.0->hyperfit) (4.67.0)
Requirement already satisfied: setuptools in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from zeus-mcmc>=2.3.0->hyperfit) (75.3.0)
Requirement already satisfied: pytest in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from zeus-mcmc>=2.3.0->hyperfit) (8.3.3)
Requirement already satisfied: matplotlib in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from zeus-mcmc>=2.3.0->hyperfit) (3.9.2)
Requirement already satisfied: seaborn in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from zeus-mcmc>=2.3.0->hyperfit) (0.13.2)
Requirement already satisfied: scikit-learn in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from zeus-mcmc>=2.3.0->hyperfit) (1.5.2)
Requirement already satisfied: six>=1.5 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from python-dateutil>=2.8.2->pandas>=1.2.0->hyperfit) (1.16.0)
Requirement already satisfied: contourpy>=1.0.1 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from matplotlib->zeus-mcmc>=2.3.0->hyperfit) (1.3.0)
Requirement already satisfied: cycler>=0.10 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from matplotlib->zeus-mcmc>=2.3.0->hyperfit) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from matplotlib->zeus-mcmc>=2.3.0->hyperfit) (4.54.1)
Requirement already satisfied: kiwisolver>=1.3.1 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from matplotlib->zeus-mcmc>=2.3.0->hyperfit) (1.4.7)
Requirement already satisfied: packaging>=20.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from matplotlib->zeus-mcmc>=2.3.0->hyperfit) (24.1)
Requirement already satisfied: pillow>=8 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from matplotlib->zeus-mcmc>=2.3.0->hyperfit) (11.0.0)
Requirement already satisfied: pyparsing>=2.3.1 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from matplotlib->zeus-mcmc>=2.3.0->hyperfit) (3.2.0)
Collecting numpy>=1.20.0 (from hyperfit)
  Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
Requirement already satisfied: iniconfig in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from pytest->zeus-mcmc>=2.3.0->hyperfit) (2.0.0)
Requirement already satisfied: pluggy<2,>=1.5 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from pytest->zeus-mcmc>=2.3.0->hyperfit) (1.5.0)
Requirement already satisfied: joblib>=1.2.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from scikit-learn->zeus-mcmc>=2.3.0->hyperfit) (1.4.2)
Requirement already satisfied: threadpoolctl>=3.1.0 in /home/hcho/mamba/envs/py12/lib/python3.12/site-packages (from scikit-learn->zeus-mcmc>=2.3.0->hyperfit) (3.5.0)
Using cached hyperfit-0.1.7-py3-none-any.whl (245 kB)
Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.0/18.0 MB 93.5 MB/s eta 0:00:00
Installing collected packages: numpy, hyperfit
  Attempting uninstall: numpy
    Found existing installation: numpy 2.0.2
    Uninstalling numpy-2.0.2:
      Successfully uninstalled numpy-2.0.2
Successfully installed hyperfit-0.1.7 numpy-1.26.4

Solution

  • Consider an env created by micromamba

    micromamba create -n py312 python=3.12 -c conda-forge
    micromamba activate py312
    

    If we've installed something with micromamba, and something else with pip:

    micromamba install urllib3
    pip install requests
    

    Things that were installed with pip will not show up in micromamba env export:

    $ micromamba env export | grep requests
    $ micromamba env export | grep urllib3
    - urllib3=2.2.3=pyhd8ed1ab_0
    

    You can also check the installer in the metadata directories:

    $ cat lib/python3.12/site-packages/urllib3-2.2.3.dist-info/INSTALLER 
    conda
    $ cat lib/python3.12/site-packages/requests-2.32.3.dist-info/INSTALLER
    pip
    

    So, you can take a look at

    grep pip lib/python3.12/site-packages/*.dist-info/INSTALLER
    

    And then uninstall them all, reinstalling them with micromamba.