Here are some resources for more information about topics covered in this lesson:
Setting Up Python on Ubuntu Linux
00:00 In this video, you’ll learn how to set up Python on Ubuntu Linux.
00:06 You’ll learn how to install Python and how to open the Integrated Development and Learning Environment, also known as IDLE. While installing Python on other Linux flavors is similar, the process you see in this video is specific to Ubuntu Linux and Ubuntu version 20.04 in particular.
00:25 You can learn how to install Python on other Linux distributions by reading Real Python’s Python 3 Installation & Setup Guide, which is linked in the description of this video.
00:36 Before you see how to install the latest version of Python, you should know that Ubuntu Linux comes with an outdated version of Python out of the box. To see that, go ahead and open a terminal window.
00:47 You can quickly open a terminal window by right-clicking on the desktop and selecting Open in Terminal.
00:58 Alternatively, you can select the Show Applications icon in your dock and search for terminal.
01:10
Inside of the terminal, type python3 --version
and press Enter. On my installation, I see that Python 3.8.5 is installed. You might see something different, but if you’ve never installed Python on your computer before, then you can rest assured that this version is out of date.
01:35 The version of Python that comes pre-installed on your computer is called system Python and you don’t want to use it. Let’s talk about why. System Python is the version of Python that comes pre-installed on your computer.
01:49 Your computer requires system Python in order to function properly because it’s used by some aspects of the operating system. You should never attempt to uninstall system Python. Doing so could cause irreversible damage to your operating system and you might be forced to wipe your hard drive and re-install Ubuntu.
02:06 So now that you know what system Python is, you’re ready to see how to install a Python version that you can actually use. There are two ways to install Python on Ubuntu.
02:17
One way is to use a package manager, such as apt
, which stands for Advanced Package Tool. The apt
package manager is used to install software from Ubuntu’s Universe repository, which is a server that hosts a collection of software maintained by Canonical, the entity responsible for developing Ubuntu Linux.
02:36
You use apt
from a terminal window. You can also install Python by compiling it from source code. You might want to do this for a couple of different reasons, such as compiling a custom version of Python for use on devices with limited memory or for accessing beta versions of Python for testing.
02:54
Compiling Python from source is an advanced process. In this lesson, you’ll be installing Python with the apt
package manager. If you’d like to see how to compile Python from source, you can find full instructions in Real Python’s Python 3 Installation & Setup Guide, which is linked in this video’s description.
03:12
All right, let’s head back to your desktop. In your terminal window, type the command sudo apt-get update
.
03:26
Before you press Enter, let’s talk about what each part of this command does. sudo
stands for “superuser do”. It allows you to run commands with elevated privileges.
03:36
These privileges are needed to make changes to your computer and its configuration, including installing some kinds of software. Running commands with sudo
will require you to enter your Ubuntu user password.
03:48
apt-get
is a part of the apt
package manager responsible for retrieving information about packages and for installing, upgrading, or removing packages from your computer.
04:00
The update
command tells apt
to download package information so that your computer receives updated information about all of the packages in the Universe repository. So in short, sudo apt-get update
tells your computer to get updated information about all of the packages you can install, including Python, using superuser privileges.
04:22 Now go ahead and press Enter to execute the command and enter your Ubuntu user password.
04:31
Once update
is done running, you’re ready to install Python. But before you do that, there’s a few things to be aware of. Python is available in a package called Python 3.9 in Ubuntu’s Universe repository. Note that Python 3.9 is the latest version of Python available at the time of this recording. For the most up-to-date package name, you can refer to Real Python’s Python 3 Installation & Setup Guide, which is linked in this video’s description.
04:59
The python3.9
package only includes the Python interpreter, which is a command line tool used to run Python programs. The package is missing two important add-ons: pip
, which is Python’s own package manager used to install third-party Python packages, and IDLE, which is Python’s Integrated Development and Learning Environment.
05:19
You’ll be using that throughout the Python Basics video series to interact with Python. So, in addition to the python3.9
package, you’ll need to install two additional packages to get pip
and IDLE.
05:31
pip
is available in the python3-pip
package and IDLE is available in the idle-python3.9
package. Let’s head on back to your desktop now to see how to install all three of these packages. In your terminal window, enter the command sudo apt-get install python3.9 python3-pip idle-python3.9
.
06:13 Then press Enter to install all three of the packages. You might need to enter your Ubuntu user password again.
06:22
Ubuntu will show you some information about the packages you’re installing and ask whether or not you’re sure you want to continue. Type y
for yes and press Enter to continue with the installation.
06:35 Depending on your internet connection, this may take a few seconds or a few minutes. Once everything finishes installing, let’s check that you now have access to Python 3.9.
06:48
Type python3.9 --version
in your terminal
07:00 You should see the version number displayed. The version of Python 3.9 installed is Python 3.9.0. Now, this is not the latest version of Python, even at the time of this recording.
07:12 That’s because the Ubuntu Universe repository is generally behind Python releases. If you’d like to see how to install the latest and greatest version of Python, check out Real Python’s Python 3 Installation & Setup Guide, linked in this video’s description. For our purposes, 3.9.0 will work just fine.
07:33
Now that you have Python 3.9 installed, you need to open IDLE to interact with it. In your terminal, type in the command idle3
and press Enter to open IDLE.
07:46
If the idle3
command doesn’t work, like it didn’t here, then as an alternative you can type idle-python3.9
to open IDLE.
08:01 This opens the IDLE shell window. At the top of the screen, you’ll see the version of Python running as well as some information about the operating system. Below this information are three red right angle brackets. These are called a prompt.
08:16 Anytime you see these, it means that Python is waiting for you to give it some instructions. Now go ahead and close IDLE as well as your terminal window.
08:30
The next time you want to open IDLE, open a terminal window by right-clicking on your desktop and selecting Open in Terminal, then typing either the idle3
or idle-python3.9
commands and pressing Enter.
08:50 So, there you go! You now know how to install Python on Ubuntu Linux and how to open IDLE, Python’s Integrated Development and Learning Environment. If you’d like to learn how to install Python on other operating systems, feel free to watch the other lessons in this course.
Become a Member to join the conversation.