pip install pipreqs
pipreqs .
This is a measure of last resort. Whoever wrote that script should have written down the requirements – as you can see, the pipreqs
program is not very good at that (which is pretty much impossible to be good at, because there's no way to know which pypi module includes which python module, so chances are you'll be wrong all the time).
So, reality here is that you're trying to automate one of the core jobs of the developer of whatever software you're trying to use.
Seeing peft
: The machine learning crowd is typically pretty OK about this; make sure you're not just blindly taking random files from complete modules that do properly declare their dependencies.
But that sometimes fails to capture all packages and all proper packages versions.
That means the requirements.txt (or whatever specifies the requirements for the different tools) is incomplete.
Nothing you can really fix in the general case – typically, this happens when a project imports something in a specific case and the developer forgets to include that in the requirements.txt (or other appropriate metadata). Knowing all specific cases would require developer knowledge, or running all possible code paths (which is infeasible).
ImportError: peft>=0.17.0 is required for a normal functioning of this module, but found peft==0.14.0.
That's a very specific error. I don't think it's generally worth trying to automate this:
