How does Python / pip handle conflicting transitive dependencies?

后端 未结 1 1132
日久生厌
日久生厌 2021-01-06 06:45

Suppose I want to install package a which requires the packages b1 and b2. In turn, b1 requires c > 1.0.0

相关标签:
1条回答
  • 2021-01-06 07:32

    In principle / other programming languages, this is not a problem. One could install two versions of c side by side and make sure that b1 uses another version than b2.

    That's not a solution. If c manages a shared resource (console, e.g.) sooner or later b1 and b2 will stomp each other input or output via different cs and you end up with incorrect input and garbage output.

    What you describe is a general problem, not limited to Python or pip. The only solution is to change b1 and/or b2 to agree on a version of c. Either downgrade b1 to allow c < 1.0 or upgrade b2 to allow c > 1.0.

    Can pip install two versions of one package?

    No, and the problem is not in pip but in Python: its import system doesn't allow importing from different versions of the same package. You can look at mitsuhiko/multiversion (Python2-only).

    0 讨论(0)
提交回复
热议问题