pip破解后如何检查包是否是“micromamba list”中的包?

问题描述 投票:0回答:1

我尝试安装一个只能通过 PyPI 获得的包 (

hyperfit
)。鉴于我已经使用
micromamba
设置了整个环境,我安装了所有依赖项,并尝试安装该包。好吧,问题是,
pip
悄悄地破坏了我的环境,没有问我。具体来说,它卸载了我最新的
numpy
并将其恢复为旧版本,但没有通知我。 (参见片段 1。)

问题是,当我运行

micromamba list
时,版本似乎没有受到pip的影响,如下例所示。

numpy                          2.0.2                py312h58c1407_0          conda-forge

当我检查Python时,它确实导入了

1.2.6
,而不是
2.0.2
,我不得不强制重新安装numpy。

问题是,我之前在 pip 上也有过类似的经历。我不知道有多少包裹在未被注意到的情况下被改变了。如何检查所有软件包是否如

micromamba list
中所示,或者至少强制
micromamba
重新安装所有软件包?

片段 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
pip mamba micromamba
1个回答
0
投票

考虑由 micromamba 创建的环境

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

如果我们使用 micromamba 安装了一些东西,并且使用 pip 安装了其他东西:

micromamba install urllib3
pip install requests

用pip安装的东西不会出现在

micromamba env export
:

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

您还可以在元数据目录中检查安装程序:

$ 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
© www.soinside.com 2019 - 2024. All rights reserved.