virtualenv on xenial: easy_install syntax error
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-virtualenv (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Xenial |
Fix Released
|
Medium
|
Stefano Rivera |
Bug Description
[Impact]
* Since Xenial has released, setuptools and pip have dropped support for
Python 3.5 (and 2.7), upstream.
* Virtualenv installs the latest upstream pip and setuptools during
virtualenv creation, from the Internet.
* Python packages gained a mechanism to declare python version support,
but this support arrived since Xenial, so virtualenv can't know which
versions of pip and setuptools are safe to install.
[Test Case]
# apt install python python3 virtualenv
$ virtualenv -p python3 ve3
$ ve3/bin/python -m pip install 'world < 4'
This should execute without error.
$ virtualenv -p python2 ve2
$ ve2/bin/python -m pip install 'world < 4'
And this should execute without error.
[Where problems could occur]
* Anyone who has discovered this broken behaviour could be suprised by the change. But they'd probably worked-around it by using venv or --no-download.
[Original Bug Report]
As of commit[0] setuptools appear to be incompatible with Python3.5 as shipped by xenial.
This makes a virtualenv for Python3 fail with a syntax error:
# virtualenv -ppython3 venv
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /root/venv/
Also creating executable in /root/venv/
Installing setuptools, pkg_resources, pip, wheel...done.
# venv/bin/pip install pyyaml
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove supp
ort for this functionality.
Collecting pyyaml
Using cached PyYAML-5.3.1.tar.gz (269 kB)
Building wheels for collected packages: pyyaml
Building wheel for pyyaml (setup.py) ... error
...
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
cmd_obj.run()
File "/root/
import setuptools.
File "/root/
):
^
SyntaxError: invalid syntax
-----
ERROR: Failed building wheel for pyyaml
# lsb_release -r
Release: 16.04
# venv/bin/python3 --version
Python 3.5.2
As Python3.5 is EOL we might need to pin setuptools for virtualenv to a lower version
[0] https:/
Changed in python-virtualenv (Ubuntu): | |
status: | New → Fix Released |
Changed in python-virtualenv (Ubuntu Xenial): | |
status: | New → Confirmed |
importance: | Undecided → Medium |
This is being tracked in setuptools upstream too
https:/ /github. com/pypa/ setuptools/ issues/ 2541
The cause is that python-virtualenv is pulling in setuptools 51.3.3
`virtualenv -p /usr/bin/python3 venv/py3 --verbose`
``` /files. pythonhosted. org/packages/ b2/81/509db0082 c0d2ca2af307c66 52ea422865de1f8 3c14b1e1f3549e4 15cfac/ setuptools- 51.3.3- py3-none- any.whl /files. pythonhosted. org/packages/ 54/eb/4a3642e97 1f404d69d4f6fa3 885559d67562801 b99d7592487f1ec c4e017/ pip-20. 3.3-py2. py3-none- any.whl /files. pythonhosted. org/packages/ 65/63/39d04c742 22770ed1589c0ea ba06c0589180121 9272420b40311cd 60c880/ wheel-0. 36.2-py2. py3-none- any.whl
....snip...
Installing setuptools, pkg_resources, pip, wheel...
Collecting setuptools
Using cached https:/
Collecting pkg_resources
Collecting pip
Using cached https:/
Collecting wheel
Using cached https:/
Installing collected packages: setuptools, pkg-resources, pip, wheel
Successfully installed pip-20.3.3 pkg-resources-0.0.0 setuptools-51.3.3 wheel-0.36.2
...snip...
```
But 51.3.0 dropped support for python 3.5 which is what ships with Xenial.
The fix would be to pin setuptools to `<51.3.0`.