Serverspace Black Friday
VB
October 3, 2022
Updated October 3, 2022

Install Python (latest version) on Ubuntu 20.04

Linux Ubuntu

What is a Python

Python is one of the most used programming language. The main advantages is relative simplicity, low learning curve, in-use versality, much third-parties designed plugins. Now this programming langage is popular for script-making, software producing, game development and even neuro-network learning. Python has cross-platform syntax and may be setup onto any actual operation system.

Method to get the newest Python

If recently developed Python is absolutely needed, you can face in-front of problem. The reason is update delay, Ubuntu repositories are not always contains the updated software versions. So, to get the most modern Python vervion please do:

  • Login into the operation system as superuser;
  • Setup all requred tools;
apt install -y software-properties-common
  • Update other exist packages;
apt-get update -y; apt upgrade -y

pic1

  • Reboot the server;
  • Include additional repository to the system pool of sources;
add-apt-repository -y ppa:deadsnakes/ppa

pic2

  • Renew the cache, then find which Python version is actual now;
apt-get update && apt-cache search python3.1

pic3

  • As we see, the hottest version is 3.11 today. So, time to get it. Just run apt manager:
apt-get install python3.11 -y

pic4

  • Next step is optional. Create symlynk for convenient using, then check the interpreter is really working:
ln -s /usr/bin/python3.11 /usr/bin/python
python --version

pic5

Building from source code

If setup via pre-built package is impossible, you also have the way to build "fresh" Python from the codes. It's so simple, just do this:

  • Login to the operation system as superuser and update system packages as discribed earlier;
  • Install building inventory;
apt-get -y update; apt -y install zlib1g-dev build-essential libgdbm-dev libncurses5-dev libssl-dev libnss3-dev libffi-dev libreadline-dev wget libsqlite3-dev libbz2-dev

pic6

pic7

  • Pull the archive to any server folder and unpack it;
mkdir /root/build
cd /root/build
wget <copied_URL>
tar -xf *.tgz

pic8

  • Switch into the folder with code files, then prepare OS to the building process;
cd <python_version>

./configure --enable-optimizations

pic9

  • Begin the building procedure and take a cup of coffee, it will take a time depends of processor power server has:
make -j $(nproc)

pic10

  • Final step is "including" package you've made to the OS:
make altinstall

pic11

  • Now ask the Python about its version, you should see picture like below.
ln -s /usr/local/bin/python3.11 /usr/bin/python
python --version

pic12

Your work is finished, well done!

In a nutshell

Now you knew about Python, its advantages and scopes of using. Also you could install it from repository or via self-building.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 2
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.