HiveBrain v1.2.0
Get Started
← Back to all entries
snippetpythonCritical

Automatically create file 'requirements.txt'

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
requirementstxtfileautomaticallycreate

Problem

Sometimes I download the Python source code from GitHub and don't know how to install all the dependencies. If there isn't any requirements.txt file I have to create it by hand.

Given the Python source code directory, is it possible to create requirements.txt automatically from the import section?

Solution

Use Pipenv or other tools is recommended for improving your development flow.

pip3 freeze > requirements.txt  # Python3
pip freeze > requirements.txt  # Python2


If you do not use a virtual environment, pigar will be a good choice for you.

Code Snippets

pip3 freeze > requirements.txt  # Python3
pip freeze > requirements.txt  # Python2

Context

Stack Overflow Q#31684375, score: 1485

Revisions (0)

No revisions yet.