Pipenv dependency resolution procedure


You are trying to install or uninstall a python package via pipenv and receive: “Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.”


Each package installed in an environment may have a number of sub-packages that are not listed in Pipfile and are managed by pipenv. When you try to change the installations in pipenv, some mismatches in these sub-dependencies may prevent further action. To resolve this you may follow this procedure:

1. Run below to clear pipenv cache

pipenv lock --clear

2. See the graph of dependencies in reverse. (You can also add –reverse to look for sub-dependencies that come under one dependency.)

pipenv graph


  - astroid==2.4.1 [requires: six~=1.12]
    - pylint==2.5.2 [requires: astroid>=2.4.0,<=2.5]
      - pylint-django==2.0.15 [requires: pylint>=2.0]
      - pylint-plugin-utils==0.6 [requires: pylint>=1.7]
        - pylint-django==2.0.15 [requires: pylint-plugin-utils>=0.5]
  - protobuf==3.11.3 [requires: six>=1.9]
    - mysql-connector-python==8.0.11 [requires: protobuf>=3.0.0]
  - virtualenv==20.0.17 [requires: six>=1.9.0,<2]
    - pipenv==2018.11.26 [requires: virtualenv]

In this case you see that the version installed for package “six” is 1.14.0. Three packages use six: astroid, protobuf and virtualenv. The version 1.14.0 does not satisfy the requirement for astroid. As it requires six~=1.12. Now you found out about the dependency mismatch.

3. When the dependency mismatch is found, try to uninstall the relevant package first.

pipenv uninstall six

4. If dependency mismatch still does not allow uninstallation, this is because the lock file is holding that dependency structure in place. You can skip that by below command

pipenv uninstall six --skip-lock

5. Then you can install the required version

pipenv install six==1.12.0 --skip-lock

6. It is also a good practice to remove ununsed dependencies.

pipenv lock --clear

7. Now you can update the environment with applied changes

pipenv update

8. If above was the only mismatch you had, you can now continue installing/uninstalling other packages in a normal fashion.