Eclipse Python Debug

From campisano.org
Jump to navigation Jump to search

Eclipse for Pyhton

Get Eclipse classic version

<pre:> wget http://eclipse.c3sl.ufpr.br/eclipse/downloads/drops4/R-4.2.1-201209141800/eclipse-SDK-4.2.1-linux-gtk-x86_64.tar.gz tar -xzf eclipse-SDK-4.2.1-linux-gtk-x86_64.tar.gz ./eclipse/eclipse

  1. Workspace: "/home/MYHOME/eclipse/pydev" # check 'use this as the default'


Get PyDev plugins

# open Eclipse
# Help -> Install New Software
# optionally uncheck 'Group items by category' to speed up the search
# Work with: click on 'Add...'
# Name: "PyDev"
# Location: "http://pydev.org/updates"
# check 'PyDev for Eclipse'
# click on 'Next >' button
# click on 'Next >' button
# accept the license
# click on 'Finish' button
# wait and restart Eclipse


Create a new Project

# open Eclipse
# File -> New -> Project # choose PyDev -> PyDev Project
# Project Name: "TestPyDevDebug"
# click on 'Finish' button
# open the PyDev perspective


Debug a Python example

# ProjectExplorer -> TestPyDevDebug -> New -> PyDev Module
# name: "TestPyDevMain"
### add this in TestPyDevMain.py ###
def add(a, b):
    return a + b

def addFixedValue(a):
    y = 5
    return y + a
  
print add(1, 2)
print addFixedValue(1)

### end add ###
# place a breakpoint in TestPyDevMain.py
# ProjectExplorer -> TestPyDevDebug -> TestPyDevMain.py -> Debug As -> Python Run
# open the Debug Perspective