This tutorial provides all the steps required to install Eclipse for Python development on Ubuntu. It explains how to install Eclipse with PyDev to develop Python applications on Ubuntu 18.04 LTS. The same setup can also be used to develop web-based applications using Django. All the steps should be similar for other versions of Ubuntu and Linux based systems.
PyDev is a plugin that enables Eclipse for Python development. It adds the features to Eclipse for Python language which includes Code Completion, Code Analysis, Debugger, Interactive Console, Refactoring, Tokens Browser, Django Integration, etc. The main advantage of installing PyDev plugin is that it can be installed on the pre-installed Eclipse that is already available on the system. We can also do a fresh install of Eclipse as shown in this tutorial.
It assumes that Java is already installed on the system. You may also be interested in How To Install Java 14 On Ubuntu, How To Install OpenJDK 14 On Ubuntu and How To Install Java 11 On Ubuntu. It also assumes that Python is already installed on the system. You may also be interested in How To Install Python 3.8 On Ubuntu 18.04 LTS.
Step 1: Download Eclipse
Open the Eclipse packages Download Page and scroll down to Eclipse IDE for Web and JavaScript Developers as highlighted in Fig 1.
Click on the Linux 64-bit link as highlighted in Fig 1. It will navigate to the download page as shown in Fig 2.
Click on the Download Button to start the download.
Step 2: Install Eclipse
In this step, we will install Eclipse for Python on Ubuntu using the file downloaded by us in the previous step. We can simply extract the zip file downloaded in the previous step to complete the installation. The files that ships with the download are shown in Fig 3.
Step 3: Desktop Shortcut
We can also create a desktop shortcut icon using the icon and executable highlighted in Fig 3 to launch the Eclipse from the desktop. In this step, we will install the GNOME panel and use the same to create a desktop shortcut to execute the Eclipse installed by us in previous steps.
# Refresh Package indexes sudo apt-get update
# Install GNOME Panel
sudo apt-get install --no-install-recommends gnome-panel
# Create Desktop icon
gnome-desktop-item-edit ~/Desktop/ --create-new
Now configure the Eclipse installation as shown in Fig 4. I have used the Eclipse icon available at the root of the installation directory.
Step 4: Launch Eclipse
We can launch the Eclipse by double-clicking on either the executable file or desktop shortcut added by us. In case you have created the desktop shortcut as shown in the previous step, it will ask to trust and launch the application for the first time. It will show the option to configure the current workspace as shown in Fig 5.
Keep the checkbox unchecked as highlighted in Fig 5. It will show the workspace selection wizard every time we launch the Eclipse IDE. After providing an appropriate workspace location, click on the Launch Button to start Eclipse. It will show the Welcome Screen as shown in Fig 6.
Now close the Welcome Tab.
Step 5: Install PyDev Plugin
Click on Help -> Eclipse Marketplace to open the Eclipse Marketplace wizard. Search for PyDev on the marketplace. It will show the search results as shown in Fig 7.
Click the Install Button to start installing the PyDev plugin for Eclipse. It will fetch the details of the plugin from the marketplace and shows the available options as shown in Fig 8.
Click the Confirm Button to confirm the plugin installation. On the next window, it will ask to accept the License Agreement as shown in Fig 9.
Click on the Finish Button to complete the installation of the PyDev plugin for Eclipse. In the end, it will also ask to restart the IDE.
Step 6: Getting Started with Python - Hello World
In this step, we will create our first Python Project using eclipse and create the first program to print Hello World on the console.
Click on Windows -> Perspective -> Open Perspective -> Other to open the PyDev perspective for Python development. It will show the list of available perspectives as shown in Fig 10.
Choose the PyDev perspective and click on the Open Button to open the perspective. The default Python Perspective is shown in Fig 11.
With the PyDev perspective open, we will create the first Python project. Click on File -> New -> PyDev Project to start creating the project. The next wizard shows the options to configure the Project as shown in Fig 12.
We can see that the project configuration wizard shows a link to configure the Python interpreter. Now click the highlighted link to start configuring the interpreter. It will show the available options as shown in Fig 13.
Click the Choose From List Button. It will show the available interpreters as shown in Fig 14.
Choose the appropriate interpreter and click the Ok Button. It will also ask to configure the python path as shown in Fig 15.
Keep the paths selected and click the OK Button. It will configure the interpreter and shows the Default interpreter selected for the project as shown in 16. It will also ask for system permission to allow Eclipse to make required changes as shown in Fig 16.
Notes: We only need to configure the interpreter for the first project. It will show the list of available interpreters from the second project onwards and we can update the interpreter configuration if required.
Click the Finish Button to complete the project configuration and create the project. It will add the project on the projects list as shown in Fig 17.
Now right-click on Src and click New -> PyDev Package and provide an appropriate package name. Click the Finish Button to create the package.
It will ask to confirm PyDev preferences for the first time as shown in Fig 19.
Click the Ok Button to confirm the preferences. We can change them later if required. It will create the Regular Package and also creates the corresponding __init__.py as shown in Fig 20.
Now we will create our first Python Module to print Hello World on the console. Keep the package selected and right-click -> New -> PyDev Module to start creating the Module. It will show the wizard to configure the Module as shown in Fig 21.
Now provide the appropriate Module name and click the Finish Button to create the module. It will also ask to choose the module template as shown in Fig 22.
I have selected the Empty Template for this tutorial to keep it simple. Click the OK Button to configure the module template. It will create the module using the empty template as shown in Fig 23.
Now update the module to print Hello World as shown in Fig 24.
Finally, we will execute the module to print the output on the console. Click on Run -> Run As -> Python Run to execute the program. It will execute the program and shows the output on the console as shown in Fig 25.
Summary
This tutorial provided all the steps to download, install and configure Eclipse with PyDev on Ubuntu 18.04 LTS. We have also created the first project, the first module, and the first package to print Hello World on the console. This is all about beginning Python programming using Eclipse with PyDev. You may join the discussion on installing Eclipse with PyDev on Ubuntu using the comment box.