Assuming you have your virtual environment activated, you have several simple approaches depending on your dependency manager:
pip
pip freeze > requirements.txt
pip3
pip3 freeze > requirements.txt
If a virtual environment is active, pip
is most certainly equivalent to pip3
.
pipenv run
pipenv run pip freeze > requirements.txt
pipenv run pip3 freeze > requirements.txt
pipenv run
spawns a command installed into the virtual environment, so these commands are equivalent to the ones run without pipenv run
. Once again, it is assumed that your virtual environment is active.
poetry
poetry export -f requirements.txt --output requirements.txt
Source: