'Unable to use pipenv to install: ImportError: cannot import name 'InstallRequirement' from 'pip_shims.shims'

Since a few hours I had issues with installing dependencies via pipenv. I decided to recreate my environment again and start from scratch, using a different python version (3.8.9). I'm now unable to even install any packages at all, and retrieve the following traceback:

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 18, in <module>
    from pip_shims.shims import (
ImportError: cannot import name 'InstallRequirement' from 'pip_shims.shims' (unknown location)

Any ideas how to resolve this?



Solution 1:[1]

For whatever reason, it seems an extended command is required, like so:

python3 -m pipenv install xyz

Before I was justing using

pipenv install xyz

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pymat