Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. It can be used to create a wide variety of programs and is not specific to any particular problem. This versatility and beginner-friendliness make it one of the most widely used programming languages today. This guide will explain to you, how to install Python on Ubuntu 18.04, and set up a programming environment.
- 99RDP Private/Dedicated Server Running Ubuntu 18.04
- Access To Terminal
Update And Add Repository
Firstly, SSH your 99RDP server, and update the local software packages and the default repository database for the system, this will prevent us from getting any errors while installing Python.
# apt-get update
# apt-get upgrade
Once the update is finished, we are going to add the “software-properties-common” package repository. It allows you to easily manage your distribution and independent software vendor sources. To add the repository run the given command in the terminal.
# apt install software-properties-common
You can also add “Deadsnake” package repository. This repository gives newer releases for packages than the default Ubuntu package archive.
# add-apt-repository ppa:deadsnakes/ppa
How To Install Python
Now browse the Python official website and check the latest stable release for Linux. For the guide, we are going to proceed with build 3.11. Enter the given command to download and install the Python build.
# apt install python3.11
Once the installation is finished add a shortcut to the Python folder using the symlink command.
# ln -s /usr/bin/python3.11 /usr/bin/python
At last to verify that the interpreter is working run the given command.
# python –version
The output will return the installed version of Python.
Managing Modules For Python With pip
Now we are going to install the pip tool which will help us download and install various modules for Python. Run the given command in the terminal to install pip.
# apt install python-pip
Once the installation is complete verify pip version by running the given command.
# pip -V
Running Your First hello.py File On Ubuntu 18.04
Once all this is done your Python installation is ready to compile codes. So let’s run a basic print function from hello.py. Enter the given text in a file using any editor and save it as hello.py.
To run the file simply type in python filename.py in the terminal and wait for the output.
# python hello.py
In this guide, we learned how to install Python’s latest build on Ubuntu 18.04. We also learned how to install pip and run a python file. Now as you have a working installation of Python 3.11 you are ready to start developing Python projects. If you have any questions or suggestions feel free to contact us.