Eclipse IDE for Python developers

Eclipse IDE for Python developers

Eclipse IDE is a wonderful piece of free IDE software and Python is the language that makes many programmers very "excited" - so why not bring them together?

Introduction to Eclipse IDE for Python developers

Eclipse IDE is an integrated development environment by the Eclipse Foundation used for computer programming that is popularly used to program Java applications. It is available for Windows, macOS and Linux.

Full functionality for Python developers can be added through PyDev. For existing Eclipse users, PyDev can be added as a plug-in. Here we will show how to install Eclipse, Python and PyDev for Eclipse and how to activate PyDev for Eclipse IDE for Windows computers.

Other options for new Python developers, probably among many others, include Raspbian (on the Raspberry Pi), PyCharm and Geany.

Installing Eclipse IDE on Windows

The Eclipse IDE installation file for Windows can be downloaded from the Eclipse Downloads page. Note that the download is provided under the terms and conditions of the Eclipse Foundation Software User Agreement. The default installation includes libraries for the JRE.

Installing Python on Windows

For PyDev to function, Python needs to be installed on your PC.

By default, some computers come pre-installed with Python, which will usually be Python 2.x. Python 2 is considered legacy, which means it is no longer maintained or supported. Python 2 and Python 3 are very similar but do have small differences when it comes to some commands.

Python 2 code cannot be executed in Python 3 and vice versa. While setting up the IDE, the version of Python installed (2 or 3) needs to be known. By repeating the installation process, multiple versions of Python can be installed on the same computer.

Python download page

The Python download page is where the Windows installer for the latest version of Python can be downloaded.

Considering this, the Windows installer for the desired version of Python (version 2.x or 3.x) can be downloaded from the python.org Python Downloads page. At the time of updating this post, the latest version of Python was 3.11.2. 32-bit and 64-bit versions are available.

Simply use the Install Now option. During the Python installation process, make sure to check the ‘Add Python 3.xx to PATH’ option. All the other installation settings can be left to their defaults.

Python Windows installer

The Windows installer of Python. In this image, version 3.8.0 will be installed. Click the checkbox (red circle) to add Python to PATH.

After the installation is finished, click on the Close button and move on to installing PyDev for Eclipse.

Installing PyDev for Eclipse

PyDev is installed onto Eclipse the same way any other Eclipse plug-in is installed.

  • In the Eclipse Workbench choose Help > Install New Software
  • Click on the Available Software Sites link and click on the Add… button
  • For the name use any name (e.g., “PyDev”)
  • For the location use http://pydev.org/updates, then click OK and OK again to go back to the Install screen
  • Under Work with: type “pydev” and select the first PyDev entry > Next
  • Click Next, Next, read and accept the license, Finish
  • If Eclipse asks whether to trust the PyDev certificate, agree
  • When the installation is complete, allow Eclipse to restart

Setting up the Eclipse, Python Interpreter

The Python interpreter is basically a program, that knows how to execute Python code. It will interpret, or translate, Python instructions into instructions that a computer can understand. After the required version of Python (version 2.x or version 3.x) has been installed, the following steps are needed to set up the Python interpreter in Eclipse (note the small differences between Python 2.x and 3.x):

  • Start > All Programs and search for the Python version installed
  • In the Python menu directory, right-click on ‘Python (command line)’ when using Python version 2.x, or right-click on ‘Python’ when using Python version 3.x
  • Select Properties
  • In the Shortcut tab, copy the target directory line (Right-click, copy).
  • In the Eclipse Workbench, choose Window > Preferences
  • Click on PyDev > Interpreters > Python Interpreter
  • In the top box, click on New… and copy the target directory from the Start Menu to the Interpreter Executable field
  • Make sure the line ends with python.exe, give it a name (i.e. Python x) and press OK, then OK again.

Creating a project with PyDev and Eclipse

To create a new Python project:

  • File > New > Project
  • In the Wizard, click on Pydev to expand it, select Pydev Project and click Next.
  • Give the project a name.
  • Make sure the grammar version matches the installed version of Python and the Interpreter is the one just set up.
  • If asked to include the Pydev Perspective, say yes.

After creating a Pydev project, the PyDev Package Explorer will be available in the Eclipse Perspectives area (top right corner of the Eclipse Workbench). To start working on a Pydev project, make sure to be in this perspective (by clicking on the perspective icon).

Hello, world

To test Eclipse’s new Python environment, get started with "Hello, World". The main file types to be used when programming in Python is Python files. Python files have .py as their extension. To create a new .py file, right-click on the Pydev Project > New > File, and name the file hello.py.

For Python 2.x use:

#!/usr/bin/python
print "Hello, World!"

and for Python 3.x use:

#!/usr/bin/python3
print("Hello, World!")

Save the file and click run (the green play triangle sign). Choose Python Run. If all is in order the result should show in the Eclipse Console (at the bottom of the screen).

Conclusion

The PyDev plug-in can extend Eclipse IDE to a Python programming environment. This post discussed how.

Leave a Reply

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