Search code examples
pythonpython-3.xpipfreeze

How to get python package requirements from another folder?


This is so simple and don't understand why it isn't working.

I have my CMD opened in folder1. Its working directory is folder1.

folder1 --> folder2

I have a bunch of python files in folder2. I would like to obtain its requirements.txt file and have it reside within folder1.

Again, with my CMD opened in folder1, I run pip freeze --path ./folder2 > requirements.txt

It returns an empty requirements.txt file within folder1. If I run pip freeze within folder2 I obtain a list of requirements no problem.

This seems so basic, but why is --path not working the way I want it?


Solution

  • My solution to this was to use pipreqs

    With CMD opened in folder1, I ran pipreqs ./folder2 --savepath requirements.txt

    A requirements.txt file appeared in folder1. The packages were based on the python files in folder2.