In nodejs, I can do npm install package --save-dev
to save the installed package into the package.
How do I achieve the same thing in Python package manager
How about make a shell function to do this ?
Add below code to your ~/.profile
or ~/.bashrc
pips() {
local pkg=$1
if [ -z "$1" ]; then
echo "usage: pips "
return 1
fi
local _ins="pip install $pkg"
eval $_ins
pip freeze | grep $pkg -i >> requirements.txt
}
then run source ~/.profile
or source ~/.bashrc
to import it to your current terminal
when you want to install && save a package, just run, for example pips requests
.
after package was installed, its version will be save into requirements.txt
in your current directory.