msalese
msalese

Reputation: 604

Ipython: Debugging Code Inside Notebook

I installed epd 7.3.2 free on amazon EWS EC2 and coinfigured ipython notebook as a public notebook server.

I run the the server in this way:

nohup ipython notebook --profile=nbserver %

Everything is working fine, I can login with password on https and code.

Now I'd like to use pdb/ipdb to debug python functions inside the notebook, but on internet I can't find the procedure how to setup the debugger.

Can someone help me ?

Regards

Massimo

These are the installed packages:

root@domU-xx-xx-xx-xx-xx-xx:/opt/epdFree7.3.2/bin# ./pip freeze
EPD==7.3
Examples==7.3
Jinja2==2.6
MKL==10.3
PIL==1.1.7
Pygments==1.4
PythonDoc==2.7.3
appinst==2.1.2
apptools==4.1.0
casuarius==1.0
chaco==4.2.0
cloud==2.4.6
configobj==4.7.2
distribute==0.6.26
enable==4.2.0
enaml==0.2.0
enstaller==4.5.6
etsproxy==0.1.1
freetype==2.4.4
idle==2.7.3
ipdb==0.7
ipython==0.13.1
kernmagic==0.1.0
matplotlib==1.1.0
nose==1.1.2
numpy==1.6.1
ply==3.4
pyaudio==0.2.4
pyface==4.2.0
pyglet==1.1.4
python-dateutil==1.5
pytz==2011n
pyzmq==2.1.11
scipy==0.10.1
tornado==2.2
traits==4.2.0
traitsui==4.2.0
wsgiref==0.1.2
wxPython==2.8.10.1

root@domU-xx-xx-xx-xx-xx-xx:/opt/epdFree7.3.2/bin# ./enpkg -l
prefix: /opt/epdFree7.3.2
Name                 Version              Store
============================================================
appinst              2.1.2-1              -
apptools             4.1.0-1              -
casuarius            1.0-1                -
chaco                4.2.0-1              -
cloud                2.4.6-1              -
configobj            4.7.2-2              -
distribute           0.6.26-1             -
enable               4.2.0-1              -
enaml                0.2.0-1              -
enstaller            4.5.6-1              api rh5-64
EPD                  7.3-0                -
etsproxy             0.1.1-1              -
Examples             7.3-0                -
freetype             2.4.4-1              -
idle                 2.7.3-1              -
ipython              0.13.1-2             api rh5-64
Jinja2               2.6-2                -
kernmagic            0.1.0-1              -
matplotlib           1.1.0-1              -
MKL                  10.3-1               api rh5-64
nose                 1.1.2-1              -
numpy                1.6.1-3              api rh5-64
PIL                  1.1.7-3              -
ply                  3.4-1                -
pyaudio              0.2.4-1              -
pyface               4.2.0-1              -
pyglet               1.1.4-2              -
Pygments             1.4-1                -
python_dateutil      1.5-2                -
PythonDoc            2.7.3-1              -
pytz                 2011n-1              -
pyzmq                2.1.11-1             -
scipy                0.10.1-0             -
tornado              2.2-1                -
traits               4.2.0-1              -
traitsui             4.2.0-1              -

Upvotes: 18

Views: 13483

Answers (3)

cd98
cd98

Reputation: 3532

Just expanding @Ken Arnold's point so people don't have to read all the answers to figure this out. As of version 1.0, debugging DOES WORK in the ipython notebook.

Just start the cell with %debug and then you'll be able to use the typical controls for ipdb ((n)ext, step, etc.).

Upvotes: 26

Ken Arnold
Ken Arnold

Reputation: 2013

Unfortunately the debugger hasn't yet been integrated into the notebook, but you can use another frontend to connect to the kernel and run the debugger there instead. The easiest way, if you have X forwarding set up, is to run %qtconsole (see http://ipython.org/ipython-doc/dev/interactive/htmlnotebook.html#workflow-and-limitations). You can also run %connect_info, then use the info it gives you to run ipython console (i.e., the ordinary terminal-mode one) connected to the same kernel.

Upvotes: 8

msalese
msalese

Reputation: 604

It' not possible !

I found this:

"Very importantly, this means that the %debug magic does not work in the notebook! We intend to correct this limitation, but in the meantime, there is a way to debug problems in the notebook: you can attach a Qt console to your existing notebook kernel, and run %debug from the Qt console."

on Ipython Doc

Now the point is :

  • remote ipython notebook --profile=nbserver is running on EWS EC2 USA
  • local ipython qtconsole is running on my pc

the JSON connection file on remote EWS EC2 is:

{
  "stdin_port": 55986,
  "ip": "127.0.0.1",
  "hb_port": 55385,
  "key": "984e86e7-4d88-4d74-8912-cbe46bc316c0",
  "shell_port": 49024,
  "iopub_port": 33440
}

Upvotes: 5

Related Questions