'Finding package requiring a specific version of another package

I have a long shell script that runs many pip installs inside a virtual env.

When installing package X, Some other, unknown package/packages are causing pip to downgrade package X to a very old version (in a loop, until it finds a compatible version). I understood this is "backtracking" that pip does to resolve the conflict, but it doesn't give info about the reason for the backtracking. I want to find out which package is causing that automatic downgrade, any advice how can i find that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source