I'm aware of pip freeze and pip list, but how do I output the packages used in a specific python file to a requiremants.txt file?
Is there an option to specify a file?
I'm aware of pip freeze and pip list, but how do I output the packages used in a specific python file to a requiremants.txt file?
Is there an option to specify a file?
No there is not. pip freeze doesn't check any of the files in your project, it simply checks the installed packages in your Python environment.
You can check all of the options that pip freeze takes here: https://pip.pypa.io/en/stable/reference/pip_freeze/
The similar pip list command does not offer such an option either: https://pip.pypa.io/en/stable/reference/pip_list/
You could try pipreqs though, it might suit your use case: https://github.com/bndr/pipreqs