Installing versions prior to Python 3.9 on 21.04
Matthew Martinez
I've upgraded to Ubuntu 21.04 as I prefer not to use the LTS releases (i.e. have later packages). I've been working on a new codebase happily with the default Python 3.9
But for an older project that runs on Python 3.6, I want to also install a version prior to 3.9 (I've hit a packaging issue around a version 3.9 issue but I'd much rather have 3.6 or 3.7 available for my virtualenv's as needed, than put in a 3.9 specific fix for a codebase that runs on 3.6 at present).
I've installed the deadsnakes ppa with sudo add-apt-repository ppa:deadsnakes/ppa and done an update. But then trying to install an earlier python version, I get a dependency issue (presumably because it's a focal package)
sudo apt-get install python3.7
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies: python3.7 : Depends: libpython3.7-stdlib (= 3.7.12-1+focal1) but it is not installable
E: Unable to correct problems, you have held broken packages. 3 1 Answer
You should compile it yourself. Use:
sudo apt-get install libssl-dev openssl
wget
tar xzvf Python-<version>.tgz
cd Python-<version>
./configure
makewhile <version> is a valid python version, e.g. 3.7.0.