Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup remote debugging with Eclipse and PyDev

I have been working with a Python program in an Ubuntu 14.04 machine, however, I would like to be able to debug that Python program using Eclipse with the PyDev plugin, but since my Ubuntu machine doesn't have a UI I would like to be able to use my Windows machine, install Eclipse + PyDev on it, and use it to remotely debug the Python program from the Linux machine. Does anybody know how to set that up? I've seen there is something called remote debugger in the PyDev website (http://www.pydev.org/manual_adv_remote_debugger.html), so I'm guessing that is something I may be able to use to do what I want, but I don't get how it works or how to set it up. Can anybody help?

like image 896
Cas Avatar asked Jan 28 '16 16:01

Cas


People also ask

How do I debug in PyDev?

Now, to debug that file, you can use Shift+F9 (the editor must be focused). NOTE: if you want to re-run the last executed file, you can use F11 to debug it (if you haven't configured F11 to always launch the last launch in debug mode, make sure you read the Getting Started on Running a program).


1 Answers

Here are the steps I took to be able to debug on Windows a program running on Linux.

  1. Open Debug Perspective in Eclipse(Windows), and start PyDev Server
  2. On linux run pip install pydevd
  3. Create a file on both windows and linux with code below
  4. Run the created script on Linux
  5. When code reaches pydevd.settrace statement it will connect to Eclipse running on Windows, and Eclipse will ask you where it can find the code, point it to where you've stored it on windows.
  6. Now you can step through the code, check variable values and etc...

    import os
    import pydevd
    pydevd.settrace("EclipseIDE_HOSTNAME", port=5678)
    
    a = 1
    b = 2
    c = a + b
    
    s = 'hello world'
    print(s)
    
like image 96
Roman Avatar answered Oct 16 '22 19:10

Roman