Search code examples
pythoneclipseversionpydevremote-debugging

Unclear which Python version is used with Remote Debugging (Eclipse Pydev)


The following guides helped me a lot with setting up Eclipse Pydev (on my local machine) and Remote debugging (on a virtual machine):

http://pydev.org/manual_adv_remote_debugger.html

http://brianfisher.name/content/remote-debugging-python-eclipse-and-pydev

If I understand things correctly, the application that I'm debugging has to be started on the remote host. So, the application uses the remote Python version.

Now, after the pydevd.settrace(), Eclipse (local host) tells me that it uses local python files in the stacktrace. Is this because of the path mapping in pydevd_file_utils.py (PATHS_FROM_ECLIPSE_TO_PYTHON)? Because some of the files are outside these mappings (threading for example).

Imagine the following case: I'm debugging my application on a production like (virtual) machine (Python 2.4) but my Eclipse is hosted on a newer dev machine (Python 2.7 by default). Will the application run under the remote 2.4 python? Or under the local 2.7 python?


Solution

  • I found the answer. I needed to test this remote debugger approach.

    Let me explain how I found out:

    I have a local system with python 2.6.5. I created a new remote system (virtual machine in this case) with python 2.7.3. Then I shared the following script:

    import pydevd
    print 'hello world'
    
    # call debugger server to handle this breakpoint
    pydevd.settrace('10.31.94.156', stdoutToServer=True, stderrToServer=True)
    
    # fron now on the host (debugger server) has control over breakpoints,
    # variables, stepping through code etc.
    print 'hi again'
    import sys
    print sys.version  # 2.7.3 (default, Sep 26 2013, 20:08:41)
                       # [GCC 4.6.3]
    
    # now use a 2.7 feature: 
    x = {i : chr(65+i) for i in range(4)}  # dict comprehension
    print x  # {0: 'A', 1: 'B', 2: 'C', 3: 'D'}
    
    import socket
    print socket.gethostname()  # my virtual machine name
    
    print 'done'
    

    Of course I added some breakpoints in Eclipse on my hostmachine. It's funny to see that the local interpreter gives errors about the list comprehension, while it does actually run. And it also has variable x nicely displayed in the debuggers Variables pane.

    Conclusion: the remote interpreter is used to run / evaluate code. The debugger server helps you ad