How to configure Eclipse for Python on Ubuntu

Eclipse is a free and open source IDE (Integrated Development Environment). One of its characteristics is its compatibility with multiple programming languages. Some of them (like Java, C++ or PHP) are integrated by default in Eclipse but other require additional configurations that must be completed by the user. This is the case of Python.

PyDev is an Eclipse plugin that enables Python integration.

This post provides detailed instructions about how to install Python in a computer and integrate it in Eclipse.

Eclipse is one of many IDEs availabe for Python. Consider it among other alternatives like the Python official IDE called IDLE or the command-line-based python.

Tested Configuration

I performed this process on Ubuntu. The steps, results and issues found may vary on different computers and OS.

In my case implied installing the following software versions:

  • Ubuntu 20.04 LTS (Focal Fossa)
  • Python 3.10.0
  • Eclipse IDE 2019-12
  • JRE openjdk 11.0.12 2021-07-20

Eclipse IDE is supposed to install JRE automatically, but I installed it myself beforehand.

Step-by-step Installation and Configuration Instructions

1. Install Python interpreter

Python is pre-installed on latest Ubuntu versions.

Type the following command to check that it is already installed:

python3 -V

It should return the Python version.

If not (i.e., you receive the reply “command not found”), you must type:

sudo apt-get install python3

2. Ensure Python works in command line

Go to command line or terminal and type python3. It should recognize the command and run the interpreter.

Inside the interpreter, type:
print("Hello world!")
The reply should be:
"Hello world!"
To quit Python interpreter and go back to cmd, type exit() o quit().

3. Install Java Runtime Environment

Eclipse IDE runs on Java, so the first step is to install Java Runtime Environment (JRE) on your Ubuntu OS.

Open a terminal and type:

sudo apt-get install default-jre

Confirm by typing “Y” if required.

It will install the latest OpenJDK version.

If you prefer the Oracle HotSpot JRE, the instructions differ, so check this link.

4. Install Eclipse IDE

To install Eclipse IDE on Ubuntu, follow the instructions on this post.

Each way of installing Eclipse IDE has its consequences, and this is why I am leaving the link instead of just summarizing the command to install it.

5. Run Eclipse

Go to “Show applications” and type “Eclipse”. Run the app.

6. Change Eclipse to a language different to English (optional)

  • Open the install wizard with ‘Help’ > ‘Install new software…’.

Install New Software in Eclipse IDE

  • Add the Babel p2 repository: https://download.eclipse.org/technology/babel/update-site/R0.19.1/2021-09/
    • Enter the URL in the “Work with” textbox
    • Click on “Add…” button
    • In the “Add repository” dialog, enter “Babel p2 repository” in “Name” textbox and click “Add” button
    • Wait. It can take some minutes.
  • Select/install your language pack of choice
    • When table is fetched, find the filter textbox and enter the text “Babel Language Pack in…”, completing the sentence with the name in English of the desired language.
    • Click “Select all” button and click “Next”

Babel Language Packs in...

    • Review the items to be installed and click “Next”
    • Accept the terms of the license agreement and click “Finish”
    • Installation progress is displayed on bottom right of Eclipse’s main screen. Wait until installation is finished
    • If a dialog informs “Warning: Installing unsigned software…”, click on “Install anyway”.
  • Restart Eclipse and you should get a translated Eclipse
    • Click “Restart Now” when restart is offered in a dialog box.
    • Eclipse will be displayed in your selected language

To read more info about Eclipse Babel Project (translations attempts for Eclipse) and get an updated Babel repository URL visit this link.

7. Install PyDev extension

While in Eclipse, go to “Help” > “Install new software…”.

Install New Software in Eclipse IDE

Add the Python repository: http://www.pydev.org/updates

  • Enter the URL in the “Work with” textbox
  • Click on “Add…” button
  • In the “Add repository” dialog, enter “PyDev” in “Name” textbox and click “Add” button
  • Wait. It can take some minutes.

Select package “PyDev”.

Optionally you can also select “PyDev Mylyn integration (optional)”), the developer resources which provide the PyDev source code. If you need help about how to install Mylyn on Eclipse, check this link.

Click “Next”

Eclipse PyDev Installation Screen

Have a look at the review screen, and click “Next”.

Review licenses in the licenses screen, accept terms and click “Finish”.

Installation progress is displayed on bottom right of Eclipse’s main screen. Wait Eclipse to complete installation.

If a dialog informs “Warning: You are installing software that contains unsigned content…”, click on “Install anyway”.

Restart Eclipse, as proposed in dialog.

If Eclipse does not start automatically, open it manually.

For more information about this installation process, check this link.

8. Configure Eclipse to work with Python

While in Eclipse, go to menu bar > “Windows” > “Preferences”

In the Preferences window, expand “PyDev”, then expand “Interpreters” and select “Python Interpreter”.

Python Interpreter at Eclipse Preferences

On the top section of “Python interpreters”, click on “New…” button > “Choose from list”

Select “/usr/bin/python3.9” from the list.

Then, the “Selection need” dialog appears with all checkboxes selected. Click on “OK”.

Selection needed dialog in Eclipse IDE

Click on “Apply and close”.

Wait until Eclipse configuration is completed. You may find the progress on the bottom right corner of Eclipse main screen.

For more info about how to configure Eclipse, check this link.

How to create and run a Python project in Eclipse

It makes sense to test the results right after you have finished the Eclipse and PyDev configurations. The best way to do it is create a simple Python project on Eclipse, run it and check if it works.

Please find the detail instructions about how to create and run a Python project in Eclipse on this other post.

You might be also interested in…

External references

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *