PyCharm remote debugging question
- I have a django project that runs fine (both locally and on a remote server).
- I start pycharm locally using a "remote debugging" profile and it looks fine.
- I see "Starting debug server at port 4000"...... "Waiting for connection"
- On the remote server, I put the appropriate call to pycharm-debug.egg in __init__.py (but I've put it other places in the code, too). More detail included below.
- I start the remote server and on the local pycharm IDE/debugger I see:
- "Connected to pydev debugger (build 133.1347)"
- After this, things just sit there... I don't get any feedback on where execution is and no ability in the pycharm IDE to "start/continue/run" anything.
- On the remote server if I <ctrl-c> it, I see:
- File "/<path here>/pycharm-debug.egg/pydevd.py", line 1256, in settrace
- File "/<path here>/pycharm-debug.egg/pydevd.py", line 1305, in _locked_settrace
- File "/<path here>/pycharm-debug.egg/pydevd.py", line 1256, in settrace
My guess is that everything is connected properly but I am not seeing a way to start everything running. I have "suspend=False" so I would have expected it to start (more details below). When I try to bring up a page against the remote server, I get "not connected" so the web server is obviously not running yet. Without remote debugging, this works fine.
What am I doing wrong? :) Thanks!
Details:
- Remote server that is running the code/process I want to debug:
- In main __init__.py I have :
- import os
- import sys
- BASE_DIR = os.path.dirname(os.path.dirname(__file__))
- sys.path.append(BASE_DIR + '/pycharm-debug.egg')
- import pydevd
- pydevd.settrace('<my local machine's public ip addr>', port=4000, suspend=False)
- import os
- In main __init__.py I have :
- Local pycharm IDE shows this:
- Starting debug server at port 4000
- Use the following code to connect to the debugger:
- import pydevd
- pydevd.settrace('localhost', port=4000, suspend=False) (tried with <public ip addr> for this, too.
- Waiting for connection...
- —- and then, after I start the remote server process: —-
- Connected to pydev debugger (build 133.1347)
- Starting debug server at port 4000
Other notes:
- I've tried this both using virtualenv and not on the remote server.
- I'm running the local pycharm IDE behind a normal Comcast cable modem router with port-forwarding for port 4000 turned on (and tested this with a node server attaching to port 4000 and worked fine when I did a wget against it from my remote server).
I'm at a loss as to how to "bump" anything to get things running and let me start debugging.
Thanks for trying to help.
Please sign in to leave a comment.
In addition to this, a handy thing to do is set up deployment configuration as well so that you can just right-click to upload newer versions of your file (under "Tools / Deployment / Configurations..."). Create a new one and under connection just use ssh creds or path to your keys. In the mappings tab, the paths are the same as what you did for the path mappings for the remote server setup. "Web path on server" was just "/" for me. After you create it, you should just be able to right-click on any file/dir and choose "Upload to...". Note that for an initial upload I just scp'd a tar.gz up to my server to save time and I only upload via the deployment configuration for the changes I do during debugging.
Good luck!
Only thing I can think of is that it's not actually running the remote interpreter. You have the option to choose which django server is being debugged when you click the debug toolbar button (there should be a dropdown). Make sure you've chosen the django server that you've configured to use the remote python interpreter. Also double check to make sure that python interpreter chosen for the django server config you're debugging is, in fact, the remote python interpreter. There should be options along the way to "test connection". Your console/debug output when you starting debugging should look something like this: "ssh://<your username>@<your server>:22/usr/local/bin/python -u /home/<your username>/.pycharm_helpers/pydev/pydevd.py –multiproc –client '0.0.0.0' –port 57402 –file /home/<your username>/<path to project on your server>/manage.py runserver <your domain>:8000"
also... are you able to upload files using the deployment config? That would also indicate whether the client is actually able to login to the server correctly, etc.
Yes, I am able to upload files to remote server (docker container): Here is the console output when I start debug in pyCharm:
ssh://docker@localhost:1338/usr/bin/python -u /home/docker/.pycharm_helpers/pydev/pydevd.py –multiproc –client '0.0.0.0' –port 46941 –file /home/docker/hydroshare/manage.py runserver 0.0.0.0:8001
Connected to pydev debugger (build 135.1057)
pydev debugger: process 234 is connecting
/usr/local/lib/python2.7/dist-packages/mezzanine/utils/conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match: None
warn("TIME_ZONE setting is not set, using closest match: %s" % tz)
/home/docker/hydroshare/hs_core/models.py:25: DeprecationWarning: django.utils.simplejson is deprecated; use json instead.
from django.utils import simplejson as json
pydev debugger: process 249 is connecting
/usr/local/lib/python2.7/dist-packages/mezzanine/utils/conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match: None
warn("TIME_ZONE setting is not set, using closest match: %s" % tz)
/home/docker/hydroshare/hs_core/models.py:25: DeprecationWarning: django.utils.simplejson is deprecated; use json instead.
from django.utils import simplejson as json
Validating models...
0 errors found
September 22, 2014 - 04:30:04
Django version 1.6.1, using settings 'hydroshare.settings'
Starting development server at http://0.0.0.0:8001/
Quit the server with CONTROL-C.
Thanks.