ModuleNotFoundError: No module named 'pip._vendor.rich.jupyter'

I have two conda environments: “base” and “test”. In the base environment, python -m pip --version shows: pip 23.3.2 from C:\ProgramData\anaconda3\lib\site-packages\pip (python 3.9). In the test environment, the same command says: “ModuleNotFoundError: No module named ‘pip._vendor.rich.jupyter’.”

The test environment’s interpreter version is intentionally different from the base environment’s. When I run python -m ensurepip --upgrade, the test environment says: “Requirement already satisfied: setuptools in c:\programdata\anaconda3\envs\test\lib\site-packages (68.2.2); Requirement already satisfied: pip in c:\programdata\anaconda3\envs\test\lib\site-packages (23.3.1)”. Previously, that version worked because I ran pip commands to install packages. How should I repair or upgrade pip? Thanks.

Hi!

Packaging is not the right category for this question; it should be moved to Python Help - Discussions on Python.org at the very least, though since this is really more of a conda question (resp. the interaction between pip & conda), it’d be even better to ask this on the conda discourse (which I see you discovered already…).

To your specific question, it needs much more information about your setup and what you’ve installed into base & test, but generally: if you’re using conda environments, don’t do python -m ensurepip --upgrade but conda update pip. The latter will ensure that no packages “owned” by conda are inadvertently overwritten by pip (or brought into an inconsistent state of version constraints, or…), which might lead to broken environments.

This situation will hopefully improve once conda has better support for PEP 668. Overall, it looks like you found a somewhat unusual sequence of commands to break things (pip-installing into conda environments does work in most cases), but again: it’s probably more fruitful to explore this on the conda discourse.

3 Likes