Skip to content

Instantly share code, notes, and snippets.

@rutcreate
Last active November 18, 2025 16:38
Show Gist options
  • Select an option

  • Save rutcreate/c0041e842f858ceb455b748809763ddb to your computer and use it in GitHub Desktop.

Select an option

Save rutcreate/c0041e842f858ceb455b748809763ddb to your computer and use it in GitHub Desktop.
Install Python 3.10.x on Ubuntu 20.04

Prerequisite

sudo apt update
sudo apt install software-properties-common -y

Add custom APT repository

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update

Press ENTER to confirm adding repository.

Install Python 3.10

sudo apt install python3.10 python3.10-venv python3.10-dev
python3 --version

You will see previous of Python. At the writing time Python 3.8.10

Make symbolic link (Optional)

Caution

This may cause problem with terminal not open on Ubuntu

https://askubuntu.com/questions/1397938/terminal-not-opening-after-changing-python-version

ls -la /usr/bin/python3
sudo rm /usr/bin/python3
sudo ln -s python3.10 /usr/bin/python3
python3 --version

Now you will see Python 3.10.x

Install PIP for Python 3.10

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
python3.10 -m pip --version

Test with system ENV

python3.10 -m pip install ipython

Test with Virtual ENV

python3.10 -m venv venv
pip install ipython

References

https://computingforgeeks.com/how-to-install-python-on-ubuntu-linux-system/

@tomislater
Copy link

Looks that this repo is dead for Focal: deadsnakes/issues#251 (comment)

@Akumar201
Copy link

@abdalrhman-hup were you able to resolve the issue ?

sudo apt install python3.10 python3.10-venv python3.10-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python3.10
E: Couldn't find any package by glob 'python3.10'
E: Unable to locate package python3.10-venv
E: Couldn't find any package by glob 'python3.10-venv'
E: Unable to locate package python3.10-dev
E: Couldn't find any package by glob 'python3.10-dev'

@vertok
Copy link

vertok commented Oct 31, 2025

@Akumar201 please first add repo where these packages are from: sudo add-apt-repository ppa:deadsnakes/ppa
then update and try again

@YangQi-Xteam
Copy link

YangQi-Xteam commented Nov 5, 2025

@Akumar201 please first add repo where these packages are from: sudo add-apt-repository ppa:deadsnakes/ppa then update and try again

I'm same. But I already exec it: sudo add-apt-repository ppa:deadsnakes/ppa
and then update

@Akumar201
Copy link

Hey, I build it from source, I am writing my commands for helping anyone seeking for answers in future


sudo apt-get update
sudo apt-get install -y --no-install-recommends \
    build-essential \
    curl \
    wget \
    libssl-dev \
    zlib1g-dev \
    libncurses5-dev \
    libncursesw5-dev \
    libreadline-dev \
    libffi-dev \
    libsqlite3-dev \
    libbz2-dev \
    liblzma-dev \
    tk-dev \
    uuid-dev

cd /tmp
curl -O https://www.python.org/ftp/python/3.10.15/Python-3.10.15.tgz
tar -xf Python-3.10.15.tgz
cd Python-3.10.15

./configure --enable-optimizations --enable-shared --with-ensurepip=install

make -j"$(nproc)"


sudo make altinstall

sudo ldconfig

#### Made it system wide default for use
sudo ln -sf /usr/local/bin/python3.10 /usr/local/bin/python
sudo ln -sf /usr/local/bin/python3.10 /usr/local/bin/python3
sudo ln -sf /usr/local/bin/pip3.10 /usr/local/bin/pip
sudo ln -sf /usr/local/bin/pip3.10 /usr/local/bin/pip3
sudo ln -sf /usr/local/bin/python3.10 /usr/bin/python
sudo ln -sf /usr/local/bin/python3.10 /usr/bin/python3
sudo ln -sf /usr/local/bin/pip3.10 /usr/bin/pip
sudo ln -sf /usr/local/bin/pip3.10 /usr/bin/pip3

#### Used update alternatives for system-wide default
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 1

#### and setup environment variables (add to ~/.bashrc)
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
echo 'export PYTHONPATH="/usr/local/lib/python3.10/site-packages:$PYTHONPATH"' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"' >> ~/.bashrc
source ~/.bashrc



#### then cleaned up 
cd /
rm -rf /tmp/Python-3.10.15*

@ictmcoraf
Copy link

Hey, I build it from source, I am writing my commands for helping anyone seeking for answers in future


sudo apt-get update
sudo apt-get install -y --no-install-recommends \
    build-essential \
    curl \
    wget \
    libssl-dev \
    zlib1g-dev \
    libncurses5-dev \
    libncursesw5-dev \
    libreadline-dev \
    libffi-dev \
    libsqlite3-dev \
    libbz2-dev \
    liblzma-dev \
    tk-dev \
    uuid-dev

cd /tmp
curl -O https://www.python.org/ftp/python/3.10.15/Python-3.10.15.tgz
tar -xf Python-3.10.15.tgz
cd Python-3.10.15

./configure --enable-optimizations --enable-shared --with-ensurepip=install

make -j"$(nproc)"


sudo make altinstall

sudo ldconfig

#### Made it system wide default for use
sudo ln -sf /usr/local/bin/python3.10 /usr/local/bin/python
sudo ln -sf /usr/local/bin/python3.10 /usr/local/bin/python3
sudo ln -sf /usr/local/bin/pip3.10 /usr/local/bin/pip
sudo ln -sf /usr/local/bin/pip3.10 /usr/local/bin/pip3
sudo ln -sf /usr/local/bin/python3.10 /usr/bin/python
sudo ln -sf /usr/local/bin/python3.10 /usr/bin/python3
sudo ln -sf /usr/local/bin/pip3.10 /usr/bin/pip
sudo ln -sf /usr/local/bin/pip3.10 /usr/bin/pip3

#### Used update alternatives for system-wide default
sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.10 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 1

#### and setup environment variables (add to ~/.bashrc)
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
echo 'export PYTHONPATH="/usr/local/lib/python3.10/site-packages:$PYTHONPATH"' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"' >> ~/.bashrc
source ~/.bashrc



#### then cleaned up 
cd /
rm -rf /tmp/Python-3.10.15*

Hello those simlinks don't work and now my python is gone ....

@ictmcoraf
Copy link

@Akumar201 can you help? followed your instructions but lost my working python 3.8.....

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