How to resolve Python package dependencies with pipenv?

I am using pipenv to handle Python package dependencies.

The Python package is using two packages (named pckg1 and pckg2) that rely on the same package named pckg3, but from two different versions. Showing the dependency tree :

$ pipenv graph
  pckg1==3.0.0
    - pckg3 [required: >=4.1.0]
  pckg2==1.0.2
    - pckg3 [required: ==4.0.11]

An attempt to install dependencies :

$ pipenv install

Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
Could not find a version that matches pckg3==4.0.11,==4.1.0,>=4.1.0 (from -r C:\Users\user\AppData\Local\Temp\pipenv-o7uxm080-requirements\pipenv-hwekv7dc-constraints.txt (line 2))
Tried: 3.3.1, 3.3.2, 3.3.3, 3.4.0, 3.4.2, 4.0.0, 4.0.0, 4.0.1, 4.0.1, 4.0.2, 4.0.2, 4.0.3, 4.0.3, 4.0.4, 4.0.4, 4.0.6, 4.0.6, 4.0.8, 4.0.8, 4.0.9, 4.0.9, 4.0.10, 4.0.10, 4.0.11, 4.0.11, 4.1.0, 4.1.0, 4.1.1, 4.1.1, 4.1.2, 4.1.2, 4.2.1, 4.2.1, 4.3.0, 4.3.0
There are incompatible versions in the resolved dependencies.

As suggested, pip install --skip-lock does the trick, but the dependency tree is still unresolved.

I would love to tell Pipenv to override pckg2's requirement, and specify pckg3>=4.1.0.

How can this be resolved?


I get that error constantly. Clearing the cache in the lock file works beautifully every time.

$ pipenv lock --pre --clear


You can't. At the moment, pipenv doesn't offer anything for an explicit override of requirement constraints.

As a workaround, you can put dependencies that you want to override to dev-packages as those will be overridden by packages, so this Pipfile should install pckg3>=4.1.0:

# Pipfile
...
[packages]
pckg1 = "==3.0.0"

[dev-packages]
pckg2 = "==1.0.2"

If you now lock and install:

$ pipenv lock --dev
$ pipenv install --dev

the requirement ==4.0.11 will be overridden by >=4.1.0. This is ugly if you ask me because this is not what development packages are meant for and you're changing the role of pckg2 dependency in project, but I don't see any better way here.


This works when there are unfinished routines on pipfile.

Once I made a mistake and run

pipenv install codecove # With an 'e' at the end

and the pipenv kept always trying to complete the installation with no success because the lib does not exist. I resolved it with:

pipenv uninstall codecove

and installed codecov after.

I tried to run

pipenv lock --clear
pipenv lock --pre --clear

but only after uninstalled the lib with wrong name I succeeded.