Home > Software engineering >  Python : how can I know which one of my dependencies is attempting to install a specific package?
Python : how can I know which one of my dependencies is attempting to install a specific package?

Time:01-11

I have a project with a requirements.txt file that is quite big ( 67 dependencies ). One of the dependencies is attempting to use the psycopg2 package installed and fails. I would prefer to install the psycopg2-binary package

How can I find witch one of the dependencies requires psycopg2 ?

I have attempted to use pip list and pip show psycopg2 but this only works if you package was installed correctly which is not my case

I have also attempted to use the pydeps tool such as pydeps requirements.txt but this gives me an assertion error witch I have yet to figure out

How can I know in advance which package is requiring directly or indirectly ( it can be through a dependency of one of my dependencies ) the psycopg2 package ?

CodePudding user response:

Try the utility pipdeptree. It shows a tree of the packages used in a pip installation with the dependencies between them.

One of the dependencies is attempting to use

Note that possibly more than one package is attempting to use that other package.

CodePudding user response:

pip by itself doesn't have this feature. You will need to use another tool. One option as Joshua Fox says is pipdeptree. Another alternative is to use poetry for dependency management instead of pip. Poetry will create a lock file that shows the dependencies of each package which you install.

  • Related