The deadsnakes PPA lets you install multiple Python versions on your Ubuntu system, so instead of only having just the Python 2.x and Python 3.x that comes with your distribution (18.04 comes with Python 3.6, and 2.7 is available), you can install older or newer versions, from 2.3 (!) to 3.8!
The way PPAs (Personal Package Archives) work is that someone maintains a personal set of apt packages on launchpad, allowing others to add their PPA to their apt sources so that “apt install” picks up their packages as well as the standard Ubuntu ones.
To add the PPA:
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update
Then to install a particular Python version:
sudo apt install python3.7
And to use it:
If you want to install pip for this Python version:
curl https://bootstrap.pypa.io/get-pip.py | sudo python3.7
Then install a library:
sudo python3.7 -m pip install gpiozero
To use IPython for a particular Python version, your best bet is to create virtual environments specific to each version, and pip install ipython into each one. You’ll need to
apt install virtualenvwrapper for this:
mkvirtualenv -p `which python3.7` py37 pip install ipython
Deactivate a virtualenv with
deactivate and activate with e.g.