I found a problem to install pyton2 virtualenv in debian 12.
To install python2 on debian 12 next command can be used:
sudo apt-get install python2
But virtualenv exists only python3-virtualenv
If try use: virtualenv -p /usr/bin/python py2venv
Will raised error:
Exception: Wheel for wheel for Python 2.7 is unavailable. apt install python2-wheel-whl
If install virtualenv by pip it return:
error: externally-managed-environment
So it is not obvious how to install python 2 virtualenv on debian 12.
Solution:
remove python3-virtualenv
sudo apt-get purge python3-virtualenv
sudo apt-get install python2
Install virtualenv version <= 20.21.1.
sudo pip install virtualenv==20.21.1 --break-system-packages
Instead --break-system-packages, can be used:
removing file /usr/lib/python3.x/EXTERNALLY-MANAGED)
adding following lines to ~/.config/pip/pip.conf:
[global] break-system-packages = true see: How do I solve "error: externally-managed-environment" every time I use pip 3?
After virtualenv -p /usr/bin/python2 py2venv
should work.
Addition: As @matt noted debian 12 droped python2 support at all, so python distribution should be installed from debian 11 distro or conda is used.