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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Extract the downloaded package using the command below.

tar -xf Python-3.8.3.tgz
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Then run command:

./configure --enable-optimizations
Enter fullscreen mode Exit fullscreen mode

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

make -j 8
Enter fullscreen mode Exit fullscreen mode

Now, install the python binaries.

sudo make altinstall
Enter fullscreen mode Exit fullscreen mode

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

python3.8 --version
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Press [ENTER] to continue or Ctrl-c to cancel adding it.
Enter fullscreen mode Exit fullscreen mode

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

sudo apt install python3.8
Enter fullscreen mode Exit fullscreen mode

After installation, verify if python is installed correctly.

python3.8 --version
Enter fullscreen mode Exit fullscreen mode

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