Skip to content

Instantly share code, notes, and snippets.

@rutcreate
Last active July 15, 2024 15:41
Show Gist options
  • Save rutcreate/c0041e842f858ceb455b748809763ddb to your computer and use it in GitHub Desktop.
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/

@CreitinGameplays123
Copy link

You saved my life

@9xcoder
Copy link

9xcoder commented May 27, 2024

thank you for sharing

@nomikk
Copy link

nomikk commented May 30, 2024

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
-> no modules name "apt_pkg"
help me

@rutcreate
Copy link
Author

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 -> no modules name "apt_pkg" help me

Make sure you install python3-apt by following command.

sudo apt install python3-apt

@nomikk
Copy link

nomikk commented May 30, 2024

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 -> no modules name "apt_pkg" help me

Make sure you install python3-apt by following command.

sudo apt install python3-apt

I tried but still get the error "apt_pkg"
Screenshot 2024-05-30 150118

@thewizardcodex
Copy link

to fix the apt_pkg issue

do this :

$ cd /usr/lib/python3/dist-packages
$ ls -la | grep "apt_pkg.cpython"
$ sudo cp apt_pkg.cpython-38-x86_64-linux-gnu.so apt_pkg.so

@thewizardcodex
Copy link

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 -> no modules name "apt_pkg" help me

Make sure you install python3-apt by following command.

sudo apt install python3-apt

I tried but still get the error "apt_pkg" Screenshot 2024-05-30 150118

do this

$ cd /usr/lib/python3/dist-packages
$ ls -la | grep "apt_pkg.cpython"
$ sudo cp apt_pkg.cpython-38-x86_64-linux-gnu.so apt_pkg.so

@Apolloelephen
Copy link

please i keep on getting this error
Screenshot from 2024-06-05 13-40-35

@dangerbrady
Copy link

Nice work

@abdalrhman-hup
Copy link

abdalrhman-hup commented Jun 13, 2024

Hi,
when I am trying to install :
ubu

Please help me
Iam using ubuntu 16.4

@rutcreate

@proxy80
Copy link

proxy80 commented Jun 30, 2024

PITFALL DONT DO Make symbolic link rm is trouble!!!!!

@paulinaSzymanska
Copy link

Thank you so much! i was searching instruction like that one! Great job!

@placccebo
Copy link

The https://gist.github.com/rutcreate/c0041e842f858ceb455b748809763ddb#make-symbolic-link section caused the terminal to fail to open. It says that the symlink cannot be changed.

@rutcreate
Copy link
Author

The https://gist.github.com/rutcreate/c0041e842f858ceb455b748809763ddb#make-symbolic-link section caused the terminal to fail to open. It says that the symlink cannot be changed.

Thanks for point it out. Now do symlink section is optional with caution.

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