DEV Community

0xkoji
0xkoji

Posted on

1 1

Create requirements.txt without pip freeze

This is completely useless for people since we can use pip freeze > requirements.txt to create a requirements.txt lol

But here is the code to do that without pip freeze command

import pkg_resources
OUTPUT_FILE = 'requirements.txt'
with open(OUTPUT_FILE, mode='w') as f:
    for dist in pkg_resources.working_set:
        requirement = dist.project_name + '==' + dist.version
        f.write(requirement + '\n')

Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more