Skip to content

Instantly share code, notes, and snippets.

@josfam
Last active December 22, 2025 14:07
Show Gist options
  • Select an option

  • Save josfam/098f5d043c94ea64d26ab34f08883384 to your computer and use it in GitHub Desktop.

Select an option

Save josfam/098f5d043c94ea64d26ab34f08883384 to your computer and use it in GitHub Desktop.
How to install python from source on linux (Ubuntu-based example)

How to install python from source on on Ubuntu (and other Debian-based distros).

Note:

  • I will use Python 3.10.19 for this example. Feel free to replace it with your preferred version.
  • Python will be installed alongside the existing version already present in your system (i.e. It will not overwrite the default python3 binary).

Steps

  • In your terminal, update the package list:
sudo apt update
  • Install the dependencies that will be useful for the build process:
sudo apt install -y \
	libbz2-dev \
	libgdbm-dev \
	libdb-dev \
	libffi-dev \
	liblzma-dev \
	libncurses5-dev \
	libreadline-dev \
	libsqlite3-dev \
	libssl-dev \
	pkg-config \
	python3-tk \
	tk-dev \
	uuid-dev \
	zlib1g-dev
wget https://www.python.org/ftp/python/3.10.19/Python-3.10.19.tar.xz
  • Extract the downloaded tar file:
tar -xvf Python-3.10.19.tar.xz
  • Navigate to the extracted directory:
cd Python-3.10.19

Inside the extracted directory, run the following commands:

  • Configure the build environment:
./configure
  • Compile the source code:
make
  • Install Python alongside the existing version already present in your system:
sudo make altinstall
  • Verify the installation by checking the Python version:
python3.10 --version

You should see the installed version of Python printed in the terminal.
for example:

Python 3.10.19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment