I use PyDev with Eclipse as an IDE.
How can I debug a tornado server running inside a docker container using PyDev/Eclipse?
Is it possible to put breakpoints in PyDev/Eclipse and debug like a server running natively on my machine?
One option is using the remote debugger, so, you can add connect the running program to the Eclipse remote debugger (see http://www.pydev.org/manual_adv_remote_debugger.html). The only thing here is that it has to create a connection from the container to the host.
Another thing which could work (as in: I've never tested it) is creating an interpreter which always runs inside docker... an interpreter in PyDev can be any executable (such as a .sh), so, you can try making a script which will run python inside docker by default (although as I never tested this I can't say how well that'll work).
Related
I have:
local PyCharm
remote server with docker container
I want run in my local PyCharm code (code on remote server) in remote docker container Python interpreter, for debug.
How to set it up?
I also found articles on the Internet, with the following description that I did not need:
local PyCharm -> ssh server interpreter
local PyCharm -> local docker
While it's not impossible to connect pycharm debugger with your remote docker container, it's much easier to use terminal interactive debugger - pdb. There are a lot of pdb flavours, if you don't like plain console
webpdb graphical debugger in a browser
pudb ncurses version, has some extra features like always listing your location in code and local variables.
I highly recommend checking them out. I use pdb on daily basis to debug python code in local docker container that has a complex run script.
I have a python script on a remote server. I would like to run it on the remote server itself. However, PyCharm is not installed on the remote server and I need PyCharm to debug the code.
I have PyCharm on my local computer and I would like to run the script (which is on remote server) on the remote server using PyCharm on my local machine. I am aware of Deployment tools and remote server host in PyCharm. I do not know how to make them work together.
Having the script on my local computer is not really an option for me as there are huge data files involved with the code and I have very limited storage on my laptop.
I'm not sure if it's absolutely necessary to use Pycharm only for debugging on your remote server but if not, you can use pdb module for debugging too: https://docs.python.org/2/library/pdb.html
I have a Djnago web application on IIS 6 on one server. Is there a way that from this website I call another python script that is on another server in such a way that that script just run itself there?
Calling or Runnig that script in the usual way as internet says, is not working.
I always get the error of os.getcwd() and it also doesn't allow to change that directory.
I just want to run that python script there on that server from this server.
Can anyone help?
Normally, I would recommend using a framework like fabric or winrm if you want to run a python script on another server. Those frameworks use ssh or windows remoting functionality, respectively, to allow a python program to execute other commands (including python scripts) on other systems. If the target machine is a windows machine, be forewarned that you can run into all sorts of UAC issues doing normal operations.
The issue I'm facing right now:
I deploy Python code on a remote host via SSH
the scripts are passed some arguments and must be ran by a specific user
the PyCharm run/debug configuration that I create connects through SSH via a different user (can't connect with the user that actually runs the scripts)
I want to remote debug this code via PyCharm...I managed to do all configuration, I just get permission errors.
Are there any ways on how I can run/debug the scripts as a specific user (like sudo su - user)?
I've read about specifying some Python Interpeter options in PyCharm's remote/debug configuration, but didn't manage to get a working solution.
If you want an easy and more flexible way to get into the PyCharm debugger, rather than necessarily having a one-click "play" button in PyCharm, you can use the debug server functionality. I've used this in situations where running some Python code isn't as simple as running python ....
See the Remote debug with a Python Debug Server docs for more details, but here's a rough summary of how it works:
Upload & install remote debugging helper egg on your server (On OSX, these are found under /Applications/PyCharm.app/Contents/debug-eggs)
Setup remote debug server run configuration: click on the drop-down run configuration menu, select Edit configurations..., hit the + button, choose Python remote debug.
The details entered here (somewhat confusingly) tell the remote server running the Python script how to connect to your laptop's PyCharm instance.
set Local host name to your laptop's IP address
set port to any free port that you can use on your laptop (e.g. 8888)
Now follow the remaining instructions in that dialog box: copy-paste the import and pydevd.settrace(...) statements into your code, specifically where you want your code to "hit a breakpoint". This is basically the PyCharm equivalent of import pdb; pdb.set_trace(). Make sure the changed code is sync'ed to your server.
Hit the bug button (next to play; this starts the PyCharm debug server), and run your Python script just like you'd normally do, under whatever user, environment etc. When the breakpoint is hit, PyCharm should drop into debug mode.
I have this (finally) working with ssh RemoteForward open, like so:
ssh -R 5678:localhost:5678 user#<remotehost>
Then start the script in this ssh session. The python script host must connect to localhost:5678 and of course your local pycharm debugger must listen to 5678
(or whatever port you choose)
I'm developing a cassandra storage finder for graphite-api.
graphite-api is installed via pip and run via gunicorn so I can't just call the script with a debugger but want to use interactive debugging.
When I import pdb in my storage finder and set a breakpoint, the code will halt there, but how can I connect now to the headless running pdb in the script?
Or is my approach to this debugging problem the wrong one and this has to be done in a completely other way?
pdb gives control over to gunicorn, which is not what you want. Have a look at rpdb or other remote debugging solutions.