virtualenv: Setuptools v45.0.0 breaks virtualenv on Python 2

Foreword: I am quite familiar with the whole January 1st, 2020 deadline and am in the process of dropping Python 2 across all my projects, but this surprise from setuptools is quite inconvenient regardless. If you chose not to fix this, I will not judge anyone, but please don’t lecture me about Python 2 being deprecated 😃


All my automated virtual environment creation scripts on Python 2 started breaking today.

Here is an example:

$ py -2.7-32 -m virtualenv foo
…
UnsupportedPythonVersion: Package 'setuptools' requires a different Python: 2.7.8 not in '>=3.5'
…
OSError: Command …\Scripts\python.exe - setuptools pip wheel failed with error code 1

This seems to be caused by the release of setuptools v45.0.0 yesterday:

v45.0.0: 11 Jan 2020

1458: Drop support for Python 2. Setuptools now requires Python 3.5 or later. Install setuptools using pip >=9 or pin to Setuptools <45 to maintain 2.7 support. 1959: Fix for Python 4: replace unsafe six.PY3 with six.PY2

https://setuptools.readthedocs.io/en/latest/history.html#v45-0-0

It seems that, by default, virtualenv tries to install the latest setuptools and that pip install setuptools picks up setuptools>=45.0.0 even though these versions don’t support Python 2.

As a workaround, I am now using the following commands:

$ py -2.7-32 -m virtualenv --no-setuptools foo
$ foo\Scripts\python -m pip install "setuptools<45"

I’m no export in Python packaging, but I would expect setuptools>=45 to declare it doesn’t support Python 2 in its distribution metadata and that pip install setuptools would automatically detect that and avoid it, but this doesn’t seem to be the case.

If that is not possible, maybe versions of virtualenv for Python 2 should avoid setuptools>=45?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 15
  • Comments: 18 (7 by maintainers)

Commits related to this issue

Most upvoted comments

The following worked for me getting out of this issue.

pip install --upgrade ‘setuptools<45.0.0’

@ostefano It was the same for me. I worked around this by installing setuptools explicitly:

$ py -2.7-32 -m virtualenv --no-setuptools foo
$ foo\Scripts\python -m pip install "setuptools<45"

However this is still critical when creating a new virtual environment for python 2.7, since virtualenv would download setuptools-45.0.0, and no upgrade (downgrade via pip with pip install --upgrade 'setuptools<45.0.0') would actually remove it. Only solution is to download the wheel manually.