What is pip's equivalent of `npm install package --save-dev`?

前端 未结 8 1906
生来不讨喜
生来不讨喜 2021-01-29 20:07

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

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-29 20:53

    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

    $ pipenv install

    This will create a Pipfile if one doesn’t exist. If one does exist, it will automatically be edited with the new package your provided.

    A Pipfile is a direct equivalent of package.json, while Pipfile.lock corresponds to package-lock.json.

提交回复
热议问题