I've been using Ubuntu 20.04 for a few months now and things are going well, however recently I ran into 2 legacy applications which I'll need to start supporting that will require Python 2. As best as I can figure, I have at least the following choices:
- Go back to Ubuntu 18.04.5
- Install Python 2 in Ubuntu 20.04
- Attempt to install Python 2 in Ubuntu 20.04 but only in a virtual environment
- Use a VM
I'd prefer to stay away from the VM option b/c I use GPUs frequently which won't go through a VM and also b/c I do a lot of hardware/software interfacing for which using a VM may cause various problems. Also I don't like VMs generally (crashes, mouse/keyboard/screen hiccups, slow performance, etc.)
I'll be honest and admit I don't use virtual environments much, however I can say I'm not inclined towards this option as the 2 legacy applications I'm going to be supporting call Python various places (calling files that start new processes, etc.) that I suspect a virtual environment won't be able to handle. Also, I'v read about problems with an entire separate version of Python in a virtual environment, ex How to create python2.7 virtualenv on Ubuntu 20.04.
Ubuntu 18.04.5 was great but I'd prefer not to backdate at this point, which leaves me to consider installing Python 2. Upon a quick Googling I found many sites that explain the steps to install Python 2 in Ubuntu 20.04 (ex https://linuxconfig.org/install-python-2-on-ubuntu-20-04-focal-fossa-linux or https://www.vultr.com/docs/how-to-install-python-2-on-ubuntu-20-04), and most of these even include instructions on how to use update-alternatives
to make python
default to Python 2, which is a necessity in my case for supporting one of the legacy options I mentioned earlier.
I find it odd that something as major as installing an entire other version of Python does not cause problems with Ubuntu, since many Linux utilities today use Python. On the other hand Python 2 is offered as an official package by Canonical https://packages.ubuntu.com/focal/python2 and they are generally very good about package integration.
At this time here are my questions:
Can anybody that has installed Python 2 in Ubuntu 20.04 clarify if this caused problems? Are there any common applications that won't work after installing Python 2? Any other "gotchas" I should know about or look out for pertaining to this?
If I continue with the instructions above (
update-alternatives
to makepython
default to Python 2) will that potentially cause problems? Any "gotchas" pertaining to this additional step in particular?Has anybody tried a Python 2 virtual environment configuration (without a Python 2 native install) in Ubuntu? Is it really as easy as this page https://computingforgeeks.com/how-to-install-python2-with-virtualenv-on-ubuntu/ makes it sound? Will virtual environments work for supporting significant applications that call other scripts, use
python
(expecting it to be Python 2), span/fork other processes, etc?If the native Python 2 install on Ubuntu 20.04 and/or the virtual environment options are problematic, are there any other good options I haven't covered here?
python2
to use scripts, and didn't experience any issues with it. The scripts though were ported topython3
and my need forpython2
disappeared & I just stopped using it.python2
is still installed I note, but I haven't used it in months (maybe even a year; I was using focal prior to its release). Refer to Thomas' answermachinectl
, …) instead, where none of the downsides you mentioned apply.from __future__ import
feature. c) Python has the2to3
and3to2
tools. d) The changes in Ruby 1.9 were much more invasive than Python 3000.