DEV Community

Daniel Kang
Daniel Kang

Posted on • Updated on

How to upgrade your Python version

On my latest post, I introduced a way to make a python IDE that you can access from anywhere. On this post, I will go over on how we can install the latest python 3.8.3 on our IDE.

For those who haven't read the post before this, I recommend you to check them out: https://dev.to/daniel2231/a-python-ide-that-you-can-use-anywhere-26cg

In this tutorial I will use an IDE called goormIDE, but you can follow this tutorial on any IDE that you wish. However, you must be using a linux based terminal if you want to follow this tutorial.

Personally, I would recommend using apt to install python as it is faster and less cumbersome.

Installing the latest Python from Source

First, update your package lists and install the packages required.

sudo apt update
sudo apt install libffi-dev libsqlite3-dev wget libbz2-dev build-essential libssl-dev libreadline-dev zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev

You will be prompt to install the packages. Press y to continue.

Alt Text

Now, download the python version you want. In this tutorial, we are going to install python3.8.3

wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tgz

Extract the downloaded package using the command below.

tar -xf Python-3.8.3.tgz

Now, after you are done extracting the installation file, switch to the python source directory and run the following command.

Move to python source directory

cd Python-3.8.3

Then run command:

./configure --enable-optimizations

After that, lets start the python build by using the following command.

make -j 8

Now, install the python binaries.

sudo make altinstall

Once that's finished, check if your python is installed correctly.

python3.8 --version

Alt Text

Yup, its correctly installed. 👍

Installing the latest Python using Apt

This
First of, run the following commands to update your package list and install the prerequisites.

sudo apt update
sudo apt install software-properties-common

Next, add deadsnakes PPA to your system's resource list. PPAs are Personal Packages Archives that lets users upload Ubuntu source packages to be built and published as apt repositories.

sudo add-apt-repository ppa:deadsnakes/ppa

You will get prompted to press Enter. Press Enter to continue.

Press [ENTER] to continue or Ctrl-c to cancel adding it.

After you are done, install the python you desire. In this tutorial, we will be installing python 3.8

sudo apt install python3.8

After installation, verify if python is installed correctly.

python3.8 --version

Presto! We got it!
Alt Text

Top comments (1)

Collapse
 
snowflakeafk profile image
Kavindu Deshapriya

Well, now python 3.10.5 is released and 3.8 was little bit outdated. For install 3.10.5 use this link
python.org/ftp/python/3.10.5/Pytho...

Replace codes according to version. Good luck