0

I am creating libraries for a large project called main. I'm having trouble understanding Python/pip's behavior when the following dependency structure exists:

  • main depends on lib1, which depends on lib2==1.0.0.
  • main depends on lib2==2.0.0.

Displayed as a tree,

main
- lib2==2.0.0
- lib1==x.x.x
  - lib2==1.0.0

This creates a bit of a snafu as my main project depends on an API provided by v2 of lib2 yet another one of the main project's dependencies depend on an earlier version of lib2.

What is Python/pip's behavior in this case? Will both libraries be installed and retained? Is there any way to gracefully resolve this version conflict?

(In npm, for example, both versions of the library will be installed and the correct version is required by the appropriate dependent library.)

  • Possible duplicate of [Installing multiple versions of a package with pip](https://stackoverflow.com/questions/6570635/installing-multiple-versions-of-a-package-with-pip) – scharette Nov 20 '17 at 14:56

1 Answers1

0

Most of the time the dependant libraries for a particular module vary based on the module version used while building them.

For eg, I ran into this problem a while ago where I installed Spacy. My project was using Numpy --version 1.0 (just as an example). But Spacy used Numpy --version 2.0.

I ran into the same issue so I just used a separate environment to run the entire project in. Installed all the modules in that environment and noticed that if Numpy was installed before Spacy and the version was older than the Numpy version used by Spacy, then it would overwrite the numpy version to keep the version date updated to module that uses it latest version.(or at least attempts to).

I may not have provided you with a definite answer, but just sharing some insights from what I've seen.

Cyrus Dsouza
  • 883
  • 7
  • 18