According to the setuptools
documentation, setuptools
version 30.3.0 (December 8, 2016) "allows using configuration files (usually setup.cfg) to define package’s metadata and other options which are normally supplied to setup()
function". Similar to running pip install -r requirements.txt
to install Python packages from a requirements file, is there a way to ask pip
to install the packages listed in the install_requires
option of a setup.cfg
configuration file?

- 4,202
- 3
- 33
- 45
4 Answers
If you have all your dependencies and other metadata defined in setup.cfg
, just create a minimal setup.py
file in the same directory that looks like this:
from setuptools import setup
setup()
From now on you can run pip install
and it will install all the dependencies defined in setup.cfg
as if they were declared in setup.py
.

- 12,032
- 3
- 54
- 53
-
3Works like a charm, as documented [here](https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files). – pandichef Jul 27 '20 at 01:54
-
6for reference `pip install .` from the same directory as setup.py – autopoietic Jun 16 '21 at 13:07
-
3Now it is even possible to accompany `setup.cfg` by empty `pyproject.toml` instead of the minimal `setup.py` to allow `pip install`. (pip 21.3.1, Python 3.8.10) – pabouk - Ukraine stay strong Jan 12 '22 at 10:50
-
4As of March 2022, with `setuptools>=61`, one can ditch `setup.cfg` in favor of `pyproject.toml` ([docs](https://setuptools.pypa.io/en/stable/userguide/pyproject_config.html)). `setuptools` is still working on letting one ditch the placeholder `setup.py` file in favor of just a `pyproject.toml` – Intrastellar Explorer May 02 '22 at 04:33
-
It does not work for me: `ERROR: You must give at least one requirement to install (see "pip help install")` MacOS 12.6.2 Chipset M1 - Python 3.10.9 – Alessandro S. Jan 10 '23 at 16:36
If your setup.cfg
belongs to a well-formed package, you can do e.g.:
pip install -e .[tests,dev]
(install this package in place, with given extras)
afterwards you can pip uninstall
that package by name, leaving deps in place.

- 11,241
- 4
- 68
- 120
-
2Excellent! Thanks - I'm using `packages = find` in my project, and `pip install -e .` worked like a charm. – Bill Horvath Jan 12 '22 at 17:35
Here is my workaround. I use the following command to parse the install_requires
element from the setup.cfg
file and install the packages using pip
.
python3 -c "import configparser; c = configparser.ConfigParser(); c.read('setup.cfg'); print(c['options']['install_requires'])" | xargs pip install
Here is a more readable version of the Python script before the pipe in the above command line.
import configparser
c = configparser.ConfigParser()
c.read('setup.cfg')
print(c['options']['install_requires'])

- 4,202
- 3
- 33
- 45
-
This script as-is does not support packages that must be installed via `dependency_links`. – argentpepper Dec 12 '17 at 20:30
No, pip does not currently have facilities for parsing requirements from setup.cfg
. It will only install dependencies along with the main package(s) provided in setup.py
.

- 1,571
- 2
- 17
- 23
-
3Or, maybe you just want the requirements to be installed, but not the actual package? AFAIK, pip doesn't have the ability to read `setup.cfg` itself, all of the options are read in to `setup.py` by `setuptools.config.read_configuration`. – rnorris Sep 13 '17 at 21:03
-
The comment by @rnorris is correct. I don't want to install the Python package itself, I want to install its dependencies. I want something like `pip install -r requirements.txt`, but something like `pip install -r setup.cfg`. – argentpepper Sep 14 '17 at 14:25
-
Pip itself does not support that. You will probably need to roll your own solution. Can I ask what you're trying to accomplish by installing the dependencies of a particular module, but not the module itself? – rnorris Sep 14 '17 at 17:03
-
4Installing the dependencies in a virtual environment in order to develop the project itself (without necessarily installing it). – argentpepper Sep 14 '17 at 17:05
-
@argentpepper I would like to have it also. Any solution to that one by now? Thank you. – Boris Brodski Jan 11 '21 at 07:01
-
4I think for the use case argentpepper mentions, `pip install --editable .` would be an appropriate solution. The intended use case of the `--editable` flag is to make the development package available in the install environment and have any source changes show up without having to re-install the package. – rnorris Jan 14 '21 at 18:06