1

I have Eclipse with Pydev and RSE installed on my local Windows machine. I want to remote debug a Python application (Odoo 9.0) that is hosted on an Ubuntu 16.04 VPS. I have Pydev installed on the remote machine. I have been able to connect to the remote machine via SSH using a key for authentication and I can browse the remote file system.

Refering to the documentation here; http://www.pydev.org/manual_adv_remote_debugger.html and reading the comments in the file located at; /usr/local/lib/python2.7/dist-packages/pydevd_file_utils.py it would seem that I need to map remote to local file system. To me this implies that the code must exist on both the remote and local (Eclipse) machines. If this is the case, how do I keep them in sync. I want to be able to develop with my code base on the remote machine. Do I need to copy every change to my local machine? It feels like I'm missing part of the puzzle and the documention that I've found is not detailed enough to be able to implement.

Please let me know what steps remain outstanding to implement remote debugging and any implications for my workflow (such as having to copy all changes to both file systems).

2 Answers 2

1

If you want to develop the code all remotely (instead of locally), my suggestion is using sshfs (so, you'd do all the changes there directly).

You should even be able to create a shell script to a remote interpreter in that case too (i.e.: the interpreter may be any script, so, you could chroot it or even run some python through ssh).

Note I haven't actually tested this, but in theory it should work ;)

Sign up to request clarification or add additional context in comments.

3 Comments

I'm afraid this doesn't address my remote debugging requirement. I appreaciate that I could always modify files on the server and execute it, but it's the benefit of doing all of this in Eclipse with debugging that I require.
Well, if you have things setup to edit remotely through sshfs, and mount it locally in the same path you have remotely, you don't need to do any additional mapping in pydevd_file_utils.py (then, when you run your program, you should be able to just use the remote debugger as said in pydev.org/manual_adv_remote_debugger.html -- note that if you only have an ssh connection, you may need to do some port forwarding).
You can also check: sites.google.com/site/programmersnotebook/… which has some step by step instructions on setting a remote env.
0

I found a way to get remote editing and remote debug going with eclipse and pydev from my mac to a Debian linux server (bitnami setup).

To set up remote editing and debugging - Read these first

https://www.pydev.org/manual_adv_remote_debugger.html https://sites.google.com/site/programmersnotebook/remote-development-of-python-scripts-on-raspberry-pi-with-eclipse

Notes on my install

  • Installed pydevd in server python environment (did not need to copy pysrc as in raspy example above instructions). See links above for install steps.
  • Created remote project using RSE. (Eclipse Remote Shell extensions) Using RSE "Remote shell" window you can right click on source directory and create a local Eclipse project that points at the server files. See links above for install steps.
  • Edited pydevd_file_utils.py in server pydevd install directory. For me this was /opt/python/lib/python3.7/site-packages. If you're not sure where this is enter the following in your server python environment import pydevd; print(pydevd.__file__). Added PATHS_FROM_ECLIPSE_TO_PYTHON = [('/Users/<myusername>/dev/test/RemoteSystemsTempFiles/<server ref in RSE>/opt/bitnami/apps/odoo/data/addons/13.0/test/test.py','/opt/bitnami/apps/odoo/data/addons/13.0/test/test.py')]. Read the comments and place it near the example lower down.
  • could add the following instead PATHS_FROM_ECLIPSE_TO_PYTHON = [(r'/Users/andrewlemay/esp/test/RemoteSystemsTempFiles/34.253.144.28/',r'/')] which means it would work for all RSE projects on the server.
  • Note the RemoteSystemTempFiles dir is part of Eclipse RSE path on your local machine
  • Add SSH remote port forwarding tunnel. This forwards the data from the server on port 5678 to client localhost:5678 to allow the server remote debugger to send info to the listening client debugger - see command below. With this I did not need IP address in settrace() command or to configure my router to port forward to my local machine.
  • INFO on SSH tunnels here https://www.ssh.com/ssh/tunneling/example

To run

  • Set up secure SSH tunnel to server with remote port forwarding on 5678
  • Run python script on server via console or RSE Remote Shell (Eclipse>Windowother>Remote systems>Remote Shell

Run commands

Client

I'm using a private shared key and I enter the following in a local terminal ssh -t -i "/Users/<username>/keys/<serverkeyname>.pem" <serverusername>@<serverIP> -R 5678:localhost:5678 -C -N The process will block the terminal. End process with CTRL-C when debugging done to close the tunnel. If you don't need a private shared key you can lose the -t -i "/Users/<username>/keys/<serverkeyname>.pem" part.

Start Pydev server in eclipse by clicking the PyDev:start the pydev server button (have to be in debug perspecive). PyDev:start the pydev server

You should then get a message in Console saying Debug Server at port: 5678

Server

You can use server terminal or Eclipse RSE Remote Shell Window Python3 test.py

The local Eclipse debug server should burst into life! and allow debugging and breakpoints etc.

Test code - test.py

import os
import sys
import pydevd
pydevd.settrace() 

i = 3
p = 'Hello!' * i
print(p)

if __name__ == '__main__':
    pass
print("Hello world 4")
for k, v in os.environ.items():
    print(f'{k}={v}')

Hope this is useful to someone...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.