How to Install Your Python Version on Ubuntu

No need for Deadsnakes nor Apt, use pyenv or conda instead!
How to Install Your Python Version on Ubuntu
How to Install Your Python Version on Ubuntu

You want to install a specific Python version, e.g., Python 3.9, on Ubuntu 23.10; neither Ubuntu PPA nor Deadsnakes PPA distributes it. Fortune has it; you don’t have to compile CPython from the source manually. And you don’t have to change your Ubuntu to an LTS version, e.g., 23.04 or 24.04, where Deadsnakes PPA supports your version.

You have these options:

  • pyenv (Simple Python Version Management)
  • conda (Anaconda or Miniconda)
  • asdf (tool version manager)
  • Docker (containerized Python possible but complex)

Pyenv

pyenv lets you easily switch between multiple versions of Python. Each version is compiled on your machine for you and for most popular versions the compilation should work reliably.

Conda

Conda instead provides precompiled version of Python for different platforms. Although the support may not be guaranteed and a compilation fallback is an option. In contrast to pyenv, conda is an environment manager and a package manager, so you can create multiple separate environments and install different precompiled packages into them.

  • Install conda from here.
  • Then you can create an environment: conda create -n my-python-3.9-environment python=3.9
  • Then you need to activate the environment: conda activate my-python-3.9-environment

asdf

Appears to be popular, but I have no experience with it. Here is an example.

asdf install python 3.7.4

Docker

This is the least practical but the most flexible and reliable approach. Dokcer is usually only used to run single version applications. Docker is not intended as a development environment. But there is a support for IDE’s like Pycharm to run a Python interpreter in Docker containers.

I hope this helps

This is a webpage I wanted to find, when a college was having this problem. I hope it helps you now.

Created on 24 Jan 2024. Updated on: 05 Mar 2024.
Thank you










About Vaclav Kosar How many days left in this quarter? Twitter Bullet Points to Copy & Paste Averaging Stopwatch Privacy Policy
Copyright © Vaclav Kosar. All rights reserved. Not investment, financial, medical, or any other advice. No guarantee of information accuracy.