@@ -789,215 +789,7 @@ This is now covered in :doc:`../topics/repeatable-installs`.
789
789
Fixing conflicting dependencies
790
790
===============================
791
791
792
- The purpose of this section of documentation is to provide practical suggestions to
793
- pip users who encounter an error where pip cannot install their
794
- specified packages due to conflicting dependencies (a
795
- ``ResolutionImpossible `` error).
796
-
797
- This documentation is specific to the new resolver, which is the
798
- default behavior in pip 20.3 and later. If you are using pip 20.2, you
799
- can invoke the new resolver by using the flag
800
- ``--use-feature=2020-resolver ``.
801
-
802
- Understanding your error message
803
- --------------------------------
804
-
805
- When you get a ``ResolutionImpossible `` error, you might see something
806
- like this:
807
-
808
- .. tab :: Unix/macOS
809
-
810
- .. code-block :: shell
811
-
812
- python -m pip install package_coffee==0.44.1 package_tea==4.3.0
813
-
814
- .. tab :: Windows
815
-
816
- .. code-block :: shell
817
-
818
- py -m pip install package_coffee==0.44.1 package_tea==4.3.0
819
-
820
- ::
821
-
822
- Due to conflicting dependencies pip cannot install
823
- package_coffee and package_tea:
824
- - package_coffee depends on package_water<3.0.0,>=2.4.2
825
- - package_tea depends on package_water==2.3.1
826
-
827
- In this example, pip cannot install the packages you have requested,
828
- because they each depend on different versions of the same package
829
- (``package_water ``):
830
-
831
- - ``package_coffee `` version ``0.44.1 `` depends on a version of
832
- ``package_water `` that is less than ``3.0.0 `` but greater than or equal to
833
- ``2.4.2 ``
834
- - ``package_tea `` version ``4.3.0 `` depends on version ``2.3.1 `` of
835
- ``package_water ``
836
-
837
- Sometimes these messages are straightforward to read, because they use
838
- commonly understood comparison operators to specify the required version
839
- (e.g. ``< `` or ``> ``).
840
-
841
- However, Python packaging also supports some more complex ways for
842
- specifying package versions (e.g. ``~= `` or ``* ``):
843
-
844
- +----------+---------------------------------+--------------------------------+
845
- | Operator | Description | Example |
846
- +==========+=================================+================================+
847
- | ``> `` | Any version greater than | ``>3.1 ``: any version |
848
- | | the specified version. | greater than ``3.1 ``. |
849
- +----------+---------------------------------+--------------------------------+
850
- | ``< `` | Any version less than | ``<3.1 ``: any version |
851
- | | the specified version. | less than ``3.1 ``. |
852
- +----------+---------------------------------+--------------------------------+
853
- | ``<= `` | Any version less than or | ``<=3.1 ``: any version |
854
- | | equal to the specified version. | less than or equal to ``3.1 ``. |
855
- +----------+---------------------------------+--------------------------------+
856
- | ``>= `` | Any version greater than or | ``>=3.1 ``: |
857
- | | equal to the specified version. | version ``3.1 `` and greater. |
858
- +----------+---------------------------------+--------------------------------+
859
- | ``== `` | Exactly the specified version. | ``==3.1 ``: only ``3.1 ``. |
860
- +----------+---------------------------------+--------------------------------+
861
- | ``!= `` | Any version not equal | ``!=3.1 ``: any version |
862
- | | to the specified version. | other than ``3.1 ``. |
863
- +----------+---------------------------------+--------------------------------+
864
- | ``~= `` | Any compatible release. | ``~=3.1 ``: version ``3.1 `` |
865
- | | Compatible releases are | or later, but not |
866
- | | releases that are within the | version ``4.0 `` or later. |
867
- | | same major or minor version, | ``~=3.1.2 ``: version ``3.1.2 `` |
868
- | | assuming the package author | or later, but not |
869
- | | is using semantic versioning. | version ``3.2.0 `` or later. |
870
- +----------+---------------------------------+--------------------------------+
871
- | ``* `` | Can be used at the end of | ``==3.1.* ``: any version |
872
- | | a version number to represent | that starts with ``3.1 ``. |
873
- | | *all *, | Equivalent to ``~=3.1.0 ``. |
874
- +----------+---------------------------------+--------------------------------+
875
-
876
- The detailed specification of supported comparison operators can be
877
- found in :pep: `440 `.
878
-
879
- Possible solutions
880
- ------------------
881
-
882
- The solution to your error will depend on your individual use case. Here
883
- are some things to try:
884
-
885
- 1. Audit your top level requirements
886
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
887
-
888
- As a first step it is useful to audit your project and remove any
889
- unnecessary or out of date requirements (e.g. from your ``setup.py `` or
890
- ``requirements.txt `` files). Removing these can significantly reduce the
891
- complexity of your dependency tree, thereby reducing opportunities for
892
- conflicts to occur.
893
-
894
- 2. Loosen your top level requirements
895
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
896
-
897
- Sometimes the packages that you have asked pip to install are
898
- incompatible because you have been too strict when you specified the
899
- package version.
900
-
901
- In our first example both ``package_coffee `` and ``package_tea `` have been
902
- *pinned * to use specific versions
903
- (``package_coffee==0.44.1b0 package_tea==4.3.0 ``).
904
-
905
- To find a version of both ``package_coffee `` and ``package_tea `` that depend on
906
- the same version of ``package_water ``, you might consider:
907
-
908
- - Loosening the range of packages that you are prepared to install
909
- (e.g. ``pip install "package_coffee>0.44.*" "package_tea>4.0.0" ``)
910
- - Asking pip to install *any * version of ``package_coffee `` and ``package_tea ``
911
- by removing the version specifiers altogether (e.g.
912
- ``python -m pip install package_coffee package_tea ``)
913
-
914
- In the second case, pip will automatically find a version of both
915
- ``package_coffee `` and ``package_tea `` that depend on the same version of
916
- ``package_water ``, installing:
917
-
918
- - ``package_coffee 0.46.0b0 ``, which depends on ``package_water 2.6.1 ``
919
- - ``package_tea 4.3.0 `` which *also * depends on ``package_water 2.6.1 ``
920
-
921
- If you want to prioritize one package over another, you can add version
922
- specifiers to *only * the more important package:
923
-
924
- .. tab :: Unix/macOS
925
-
926
- .. code-block :: shell
927
-
928
- python -m pip install package_coffee==0.44.1b0 package_tea
929
-
930
- .. tab :: Windows
931
-
932
- .. code-block :: shell
933
-
934
- py -m pip install package_coffee==0.44.1b0 package_tea
935
-
936
- This will result in:
937
-
938
- - ``package_coffee 0.44.1b0 ``, which depends on ``package_water 2.6.1 ``
939
- - ``package_tea 4.1.3 `` which also depends on ``package_water 2.6.1 ``
940
-
941
- Now that you have resolved the issue, you can repin the compatible
942
- package versions as required.
943
-
944
- 3. Loosen the requirements of your dependencies
945
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
946
-
947
- Assuming that you cannot resolve the conflict by loosening the version
948
- of the package you require (as above), you can try to fix the issue on
949
- your *dependency * by:
950
-
951
- - Requesting that the package maintainers loosen *their * dependencies
952
- - Forking the package and loosening the dependencies yourself
953
-
954
- .. warning ::
955
-
956
- If you choose to fork the package yourself, you are *opting out * of
957
- any support provided by the package maintainers. Proceed at your own risk!
958
-
959
- 4. All requirements are loose, but a solution does not exist
960
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
961
-
962
- Sometimes it's simply impossible to find a combination of package
963
- versions that do not conflict. Welcome to `dependency hell `_.
964
-
965
- In this situation, you could consider:
966
-
967
- - Using an alternative package, if that is acceptable for your project.
968
- See `Awesome Python `_ for similar packages.
969
- - Refactoring your project to reduce the number of dependencies (for
970
- example, by breaking up a monolithic code base into smaller pieces)
971
-
972
- .. _`Getting help` :
973
-
974
- Getting help
975
- ------------
976
-
977
- If none of the suggestions above work for you, we recommend that you ask
978
- for help on:
979
-
980
- - `Python user Discourse `_
981
- - `Python user forums `_
982
- - `Python developers Slack channel `_
983
- - `Python IRC `_
984
- - `Stack Overflow `_
985
-
986
- See `"How do I ask a good question?" `_ for tips on asking for help.
987
-
988
- Unfortunately, **the pip team cannot provide support for individual
989
- dependency conflict errors **. Please *only * open a ticket on the `pip
990
- issue tracker `_ if you believe that your problem has exposed a bug in pip.
991
-
992
- .. _dependency hell : https://en.wikipedia.org/wiki/Dependency_hell
993
- .. _Awesome Python : https://python.libhunt.com/
994
- .. _Python user Discourse : https://discuss.python.org/c/users/7
995
- .. _Python user forums : https://www.python.org/community/forums/
996
- .. _Python developers Slack channel : https://pythondev.slack.com/
997
- .. _Python IRC : https://www.python.org/community/irc/
998
- .. _Stack Overflow : https://stackoverflow.com/questions/tagged/python
999
- .. _"How do I ask a good question?" : https://stackoverflow.com/help/how-to-ask
1000
- .. _pip issue tracker : https://github.com/pypa/pip/issues
792
+ This is now covered in :doc: `../topics/dependency-resolution `.
1001
793
1002
794
.. _`Using pip from your program` :
1003
795
0 commit comments