Reputation: 61
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).
Upvotes: 1
Views: 1538
Reputation: 9
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
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.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.To run
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...
Upvotes: 0
Reputation: 25372
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 ;)
Upvotes: 1