How to add Python 3 as interpreter in Eclipse

Python 3 as interpreter in Eclipse
Python 3 as interpreter in Eclipse

The PyDev plugin adds support for working with Python files to Eclipse. However, it is only auto-configured to work with a Python 2.x interpreter. Furthermore, Ubuntu installs Python 2.x by default and needs some manual work to work with Python 3.x.

To use Python 3.x for your Python files in Eclipse:

  • First install Python 3.x:
$ sudo apt install python3
  • This installs the Python 3.x interpreter as /usr/bin/python3. We will use this in Eclipse.

  • In Eclipse, open Preferences -> PyDev -> Interpreters -> Python Interpreter. Click Add and add /usr/bin/python3. The Libraries and other settings will be auto-discovered by PyDev.

  • That is it! When you create a new Python project, in its dialog remember to pick Grammar version as 3.0 and the Interpreter as Python3.

Tried with: Python 3.4.0, PyDev 3.9.0, Eclipse Luna 4.4.1 and Ubuntu 14.04

How to ignore PEP8 error or warning in PyDev

Ignore PEP8 warning or error in PyDev
Ignore PEP8 warning or error in PyDev

PyDev can be configured to analyze your code to check if it complies with the PEP8 guidelines. It generates errors and warnings if the code does not comply. For example, E501 complains if a line is longer than 80 characters.

Sometimes, you may want to ignore some specific errors or warnings of PEP8. To do this, go to Windows -> Preferences -> PyDev -> Editor -> Code analysis -> Here add an --ignore string with the error and warning numbers you want ignored. For example, --ignore=E501. Restart Eclipse for changes to take effect.

Tried with: PyDev 3.9.0, Python 3.4.0, Eclipse Luna 4.4.1 and Ubuntu 14.04

How to piece together your own Eclipse

Compared to Eclipse CDT package, my Eclipse C++ IDE has very few features and plugins
Compared to Eclipse CDT package, my Eclipse C++ IDE has very few features and plugins

Eclipse is developed as a modularized system with a central core platform and additional features and plugins that provide functionality required for a certain language (like Java or C++). These packaged versions of Eclipse that are put together for different languages is what is provided on its download page.

You may feel that the Eclipse packages available for Java or C++ (CDT) are extremely bloated with hundreds of features and plugins that you may never use. For example, Eclipse CDT includes hundreds of MyLyn features and cross-compiler support, none of which I may require right now. The beauty of Eclipse is that everything is a plugin, so you can actually build yourself a lean Eclipse that only includes what you want. This way you can build a minimal Eclipse that has only the features you want.

Step 1: Get the platform runtime binary

  • The core of Eclipse is provided for download as Eclipse Platform Runtime Binary. To get it, go to this page and click on the build number you want. It opens a new page, where you scroll down to the section named Platform Runtime Binary and download the package matching your system.

  • Unzip the zip file you downloaded and run the eclipse binary file. The IDE opens and it works.

Step 2: Add the plugins

  • Now add the plugins you want from Help -> Install New Software. For plugins provided by Eclipse, choose Luna from the dropdown. For external plugins, add their URL.

  • For creating a Eclipse C++ IDE of my own, I installed these plugins:

  • For creating a Eclipse Python IDE of my own, I installed these plugins:

Tried with: Eclipse 4.4.2 and Ubuntu 14.04

How to install PyDev

PyDev brings support for working with Python files to Eclipse. Installing the PyDev plugin for Eclipse is very easy:

  • Go to Help -> Install New Software. Click on Add and add if you want the Stable version or if you want the bleeding edge versions.

  • PyDev appears in the list below, choose it and follow through the dialog, giving it install permissions and it will be installed. You will need to restart Eclipse to use PyDev.

Tried with: Eclipse Luna 4.4.1 and Ubuntu 14.04

How to manually install PyDev

The easiest and recommended method to install PyDev is to use Install New Software as shown here. I found that this method was giving this error on Eclipse 4.4.1:

An error occurred while collecting items to be installed
session context was:(profile=epp.package.cpp, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
Unable to read repository at
Read timed out
Unable to read repository at
Read timed out

Thankfully, PyDev plugin can be installed manually and that is what I ended up doing:

  • Download the latest plugin zip files from here.

  • Unzip the file and you get two directories features and plugins. Place these directories in the dropins directory of your Eclipse installation.

  • Restart Eclipse if it was running.

  • Go to Help -> Installation Details. You should be able to find PyDev listed here.

You should be able to use PyDev now! 🙂

Tried with: PyDev 3.9.0, Eclipse Luna 4.4.1 and Ubuntu 14.04

Eclipse: Find and Search

Eclipse is a strange beast. To search for a string, I was using the common Ctrl+F keyboard shortcut. This would pop up the familiar Find/Replace dialog. But soon, I was looking for a way to search through the entire project or workspace and could not find any way to do that using the Find/Replace dialog.

It turns out that there a larger, more complex Search feature in Eclipse! Why they would keep both Find and Search instead of combining them (like Visual Studio), that I cannot fathom. Ctrl+H is the default keyboard shortcut for this Search and indeed it shows up with custom searches for all the languages supported by Eclipse. (I use the PyDev Search, since I use Eclipse for Python code.)

The editor does not show the first matching search result (like in Find/Replace), but shows the Search results in a new Search window at the bottom. All in all, very odd business. But, at least I can now search through the entire project/workspace.