Categories
Python Answers

What is Python pip’s equivalent of npm install package –save-dev?

Spread the love

In Python’s pip, there isn’t a direct equivalent to npm install package --save-dev, because Python’s dependency management system doesn’t make a distinction between dependencies needed for development and those needed for production.

However, you can achieve a similar effect by using pip to install the package and then manually adding it to a requirements.txt file with an appropriate comment indicating that it’s a development dependency.

Here’s how you can do it:

  1. Install the package using pip:
pip install package_name
  1. Manually add the package to your requirements.txt file with a comment indicating it’s for development:
package_name  # for development

This way, you have a record of the package in your requirements.txt file, and it’s clear that it’s a development dependency.

When someone else wants to install the dependencies, they can run pip install -r requirements.txt, and all dependencies, including those for development, will be installed.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *