Posts Tagged ‘eric’

Debugging in Python

April 24, 2011 4 comments

If you are doing debugging with “print“, it’s time to try one of the following methods.

Debugging with pdb/ipdb

If you want a clear and gentle introduction to the usage of the Python debugger “pdb“, read Steve Ferg’s excellent tutorial Debugging in Python.

Here I make a short summary for reference purposes:

  • import pdb” or “import ipdb as pdb“, then “pdb.set_trace()
  • n (next)
  • ENTER (repeat previous)
  • q (quit)
  • p <variable> (print value)
  • c (continue)
  • l (list where you are)
  • s (step into subroutine)
  • r (continue till the end of the subroutine)
  • ! <python command>

ipdb is like pdb but it adds syntax highlightning and completion. You can install it with “sudo pip install ipdb“. If you used pdb with “import pdb“, just change this line to “import ipdb as pdb“. This way the line “pdb.set_trace()” can be left unchanged.

Debugging with Winpdb

Another interesting debugger is Winpdb, which is a platform independent GUI debugger for Python with support for multiple threads, namespace modification, embedded debugging, encrypted communication… It can be installed from the Ubuntu repos (sudo apt-get install winpdb). Tutorial here.

Short summary again:

  • restart (restart debugging session)
  • exit
  • n (next)
  • go (continue)
  • x <python command> (exec, changes state)
  • v <python command> (eval, print to console, no changes in state)
  • j <line> (jump)
  • s (step in subroutine)
  • r (return from subroutine)
  • bp <line> (breakpoint @ line)
  • bp <line>, <expression> (conditional breakpoint @ line)
  • bl (breakpoint list)
  • bc <id> | * (breakpoint clear)

Debugging with the Eric IDE

I would sum up how to debug with the Eric IDE too:

  • F5 (start debugging; untick “Don’t stop at first line” or set a breakpoint)
  • F10 (stop)
  • F7 (next, step in subroutines)
  • F8 (next, step over subroutines)
  • F9 (return, step out of subroutine)
  • F6 (continue, go, run)
  • Shift+F6 (continue till cursor)
  • conditional breakpoints are supported (set a breakpoint, right click on it, edit)

I find Eric’s debugger is much faster than Winpdb.

Update (20141227)
If you want to add a break point to your script and you want to “break out” to ipython, then just add this line:

import ipdb; ipdb.set_trace()
Categories: python Tags: , , , , ,

GUI for the output of PyLint

April 7, 2011 Leave a comment


I discovered PyLint yesterday and after some tests I find it very useful. However, one thing bothered me in the workflow. PyLint tells you where (in which lines) you should improve your code but if you add/remove some lines in the source, these line numbers become invalid. Thus, you need to relaunch pylint lots of times until you resolve all the problems.


Idea: make a simple GUI that shows the output of PyLint. If necessary, refresh the content of this window.


Visit Source code is here.

Usage: <>

You can refresh the content by pressing ‘r’, ‘u’, or F5.

Update (20110408)
This morning I was notified that PyLint has a simple GUI that is shipped with it; it’s called pylint-gui :)) Great! Why is it nowhere mentioned on the project’s home page? I’ve read several reviews too, nobody says it has a GUI… Now I searched for the string “gui” in the manual and yes, they mention it in two lines, but no screenshot! Either you read it word by word or you miss it. To fill the gap, here is my screenshot of the mysterious pylint-gui:

Well, if you prefer minimal design, you can try Pylov :) Otherwise use the official GUI.

Update (20110426)
I made Pylov because the PyLint plugin of the Eric IDE didn’t have the refresh option. I contacted the author of Eric and he added this feature :) So if you use Eric, it is recommended to use the PyLint plugin.

[ @reddit ]

Categories: python Tags: , , , , ,

Install the Eric Python IDE

March 15, 2011 Leave a comment

Eric is a full featured Python and Ruby editor and IDE, written in Python. It is based on the cross platform Qt GUI toolkit, integrating the highly flexible Scintilla editor control. It is designed to be usable as everdays’ quick and dirty editor as well as being usable as a professional project management tool integrating many advanced features Python offers the professional coder. Eric4 includes a plugin system, which allows easy extension of the IDE functionality with plugins downloadable from the net. Current stable versions are eric4 based on Qt4 and Python 2 and eric5 based on Python 3 and Qt4.” (source)

As I’m still using Python 2, I will show you how to install eric4. Unfortunately, there is a very old version in the official Ubuntu repositories. Let’s see how to install an up-to-date version.

First, install it via apt-get. The advantage here is that all the dependencies will be installed.

sudo apt-get install eric

Apt-get will suggest some additional packages, it’s a good idea to install them too. Then, download the latest stable version of eric4. Remove the old version that we installed via apt-get:

sudo apt-get remove eric

Remember, the dependencies remain, so we can install the latest version without any problem. Uncompress the downloaded archive and execute as root:

sudo ./

Now you can start the editor with “eric4“.

I find it a very nice IDE for Python. It has tons of cool features still it’s lightweight. If I want to edit a simple script, I won’t start Eclipse (with the Python plug-in), it’s too slow… But if I want more than pure vim :), eric4 is a good choice.


In my case, the installer didn’t work perfectly: it didn’t set the rights correctly, thus I couldn’t execute eric4 as a normal user. I asked some people, they said they didn’t have this problem… Anyway, here is what I had to do:

  • Copy (see below) to /usr/lib/python2.6/dist-packages/eric4 and execute it as root. It will correct the rights.
  • Repeat the step above with the directory /usr/lib/python2.6/dist-packages/eric4plugins too.


find . -type d -print0 | xargs -0 chmod 755
find . -type f -print0 | xargs -0 chmod 644
chmod 755 .
chmod u+x $0

There is one more step to do: copy (from the uncompressed install directory) to /usr/lib/python2.6/dist-packages/eric4. Don’t forget to set its rights (chmod 644

Now, you should be able to start the IDE with “eric4“.

Update (20110401)

I have this problem with the wrong permissions with other packages too that I install with “pip”, so this is not an eric-specific issue. But with the bash script above I can correct it easily.

Categories: python Tags: , , , ,