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 pip
? I would like to save the package name and its version into, say, requirements.pip
just after installing the package using something like pip install package --save-dev requirements.pip
.
I made a quick hack on
pip
to add--save
option to install/uninstall commands.Please have a look at my blog for more information about this hack: http://blog.abhiomkar.in/2015/11/12/pip-save-npm-like-behaviour-to-pip/
Installation (GitHub): https://github.com/abhiomkar/pip-save
Hope this helps.
Update: apparently, pipenv is not officially endorsed by Python maintainers, and the previously-linked page is owned by a different organization. The tool has its pros and cons, but the below solution still achieves the result that the OP is seeking.
pipenv is a dependency management tool that wraps
pip
and, among other things, provides what you're asking:https://pipenv.kennethreitz.org/en/latest/#example-pipenv-workflow
A
Pipfile
is a direct equivalent ofpackage.json
, whilePipfile.lock
corresponds topackage-lock.json
.