How to run Python on Ubuntu 20.04

Most Linux distros have Python already installed by default. To check this, open up your terminal and type in python3.6. You will notice that the prompt will change.

Python shell command

In this new console you can execute commands in Python.

Read: A Comprehensive Guide to Installing GCC on Ubuntu 22.04

Installing PyCharm

In order to be able to program in Python, you could use the pre-installed package. To save time however, we will install an IDE, which is a software that will make it easier for you to program in Python.

Perhaps the best option for Python is PyCharm , it is very complete, light, and quite beautiful.

On the download site choose the community version, which is free, but more basic for our purpose, it will serve perfectly. If I’m not mistaken there is a Snap package for Ubuntu (and any distro) from it, if you use Deepin, it’s on the Deepin AppStore.

PyCharm Python IDE for Ubuntu

After the download is finished, you will have a .tar.gz file , unzip it, enter the folder that was created and enter the bin folder .

Read: Gunzip command in Linux

Inside this folder there is a file called pycharm.sh which is the installer. In order to run it, open up the terminal, navigate to the file folder and type in ./pycharm.sh. This will start the installation.

Install PyCharm Ubuntu

The first window that opens up will ask if you want to restore data from past installations, in our case we will not do that. Accept the terms of use and finally, a window where you can customize the interface will open. Leave the default settings.

Read: How to Create an executable from a Python program

The next step is to create a project and choose the location where our Python files will be stored.

Read: How to install Python on Ubuntu 22.04 

Don’t forget to choose the version of Python you want to work with. Now, let’s create a new file.

Click on file (on the top menu) and then on new …, a small window will open, select Python file , name it and write the following:

print (‘Hello everyone‘)

You may have to wait a while if this is your first time opening PyCharm. As in the image above, Pycharm will be indexing some files, so it’s good to wait a while and let that happen.

Read: 6 Reasons why you Should Learn Python

To run your code, go to the Run menu and click Run again, the execution will look like this:

Basically everything is ready and working, but we have two more tips for you:

1 – To choose the Python version of your project go to:

File (in the top menu) -> settings and in the window that opens select project/python interpreter and then select the desired version.

Read: How to create a Modern Python Development Environment

2 – If you like to use shortcuts, go to help (top menu), keymap references and a PDF will open with all IDE shortcuts. You may want to check it out as it can help speed up your work.


If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.

 

amin nahdy

Amin Nahdy, an aspiring software engineer and a computer geek by nature as well as an avid Ubuntu and open source user. He is interested in information technology especially Linux based ecosystem as well as Windows and MacOS. He loves to share and disseminate knowledge to others in a transparent and responsible way.

Leave a Reply