Score:0

Installing versions prior to Python 3.9 on 21.04

vn flag

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 https://github.com/hzdg/django-enumfields/commit/8a54ab6ca1a406b4f736b1d8a1daff49431a1c5c 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.
Ben avatar
in flag
Ben
If you need many versions of Python, and prefer more up-to-date packages, Miniconda may be a good choice. It also works cross platform.
us flag
The deadsnakes PPA is only for LTS versions of Ubuntu. @Ben maybe write an answer with how to configure miniconda with python3.6.
vn flag
Thanks @Ben Anaconda always struck me as a huge collection but I wasn't aware of miniconda. I'll see how I progress and update here if it works for me.
Score:-1
ng flag

You should compile it yourself. Use:

sudo apt-get install libssl-dev openssl
wget https://www.python.org/ftp/python/<version>/Python-<version>.tgz
tar xzvf Python-<version>.tgz
cd Python-<version>
./configure
make

while <version> is a valid python version, e.g. 3.7.0.

ru flag
This may overwrite or collide with the system installed Python - usually I suggest `pyenv` be used here for creating userspace Python installs that won't conflict.
Emoji avatar
ng flag
@ThomasWard Removed `sudo make install`.
Emoji avatar
ng flag
Without make install, you system will be remain unchanged, so don't worry.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.