Require minimum Python version in

1 minute read

Almost everyone uses setuptools.setup in their The field python_requires allows fine-grained control of which versions of Python are supported. Let’s explain the use of this by example. We assume that is structured like

from setuptools import setup, find_packages


NOTE: You must install packages (including those local on your hard drive e.g. a Git repo) with

python -m pip install -e .


python develop

as the latter ignores python_requires. Both methods use *.egg-link in site-packages/ so that you’re always using what’s in your ~/code directory, not a frozen .egg version.

Python ≥ a version

This is by far the most common use case, to avoid confusion from the few users still on Python 2. Many Python users have at least Python 3.5, and Python 3.6 has been widely available and supported for some time. Many of my programs have


or even


Python ≤ a version

Let’s say you have one of those rare programs that doesn’t run on Python 3. You can forbid Python 3 from installing it by setting


or since we know Python 2.7 is the last Python 2 version


Inclusive Range of Python versions

Let’s say your program only works for Python 2.6 and 2.7.


Even more options found in the reference below.


specification reference

Leave a Comment