Last active
November 14, 2020 01:59
-
-
Save abmohan/b92a9f2316557598951a11089e727a45 to your computer and use it in GitHub Desktop.
pip install and save dependencies (i.e. Python equivalent of `npm install --save`)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install and save to (and sort + dedupe) requirements.txt | |
function pip-save { | |
# loop through all listed requirements | |
for var in "$@" | |
do | |
# attempt to install it | |
pip install $var | |
# add it to the requirements.txt file | |
pip freeze | grep -i "^$var=" >> requirements.txt | |
done | |
# sort requirements.txt and remove duplicates | |
sort -u requirements.txt -o requirements.txt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good tip. You should take a look on Poetry as an easy npm like python all-in-one environment/dependencies manager.
It is great and so easy to use. Forget requirements.txt, conda, pipenv and messing your python environment.