6

My source code is stored on a remote machine and I want to remotely code and debug my Python source code. How should I configure PyCharm to enable remote debugging?

3 Answers 3

2

For remote debug you need to copy the sources to your local machine, set up a project, configure deployment to the remote machine and add remote Python interpreter to run and debug on the remote system.

It's not possible to work with the source files that are not on the machine where PyCharm is running.

You can find details about deployment and remote interpreter configuration in PyCharm help.

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

2 Comments

Not know whether I misunderstood what you mean of It's not possible to work with the source files that are not on the machine where PyCharm is running. But remote debug is the meaning of the interpreter and source code are all in the remote. And Pycharm can do this with path mapping.
@Honghe.Wu it's not recommended to use network drives/mounts for the performance reasons, make a local copy of the project.
2

Just as @CrazyCoder say above.
You need to copy the sources to your local machine, set up a project, configure deployment to the remote machine and add remote Python interpreter.

But you can use remote Python interpreter to debug remote source code with set source code path mapping on (detail Ref)

Run | Edit Configurations...

I think remote debug means the interpreter and source code are all in the remote.

enter image description here

Or through vagrant with Pycharm Pycharm Configuring to work on a VM

Comments

1

I recently did it, it took a while to get it working but I think it is pretty straight forward once you know what needs to be done.

A bit of explanation on what is happening:

There are 2 parts, the debug server which is your computer (where pycharm is running so it is a little confusing) and the server where the application is running (which you might usually think of as the server but for now will be the dev machine). This means the code should have you computers IP (the debug server) and the correct port, and then they can talk and be happy and buggy.. I mean debuggy. When the dev machine runs the script there will be a command that tries to connect to the debug server (your pycharm)

Actual setup:

First let us set up the debug server, just follow the instructions here (skip the part about the egg we will be right there). Make sure you have set the paths (so remote and local path lead to project root because he looks for the files during debug). Also I find it easier to use a constant port rather then a dynamic one as I dont want to update the code on the server each time.

Note - you need to run the debug server so a program will be able to connect when debugging, dont forget this.

Next we need to configure the dev machine. First step is to install the debug egg which is easily done by copying it to anywhere in the dev machine and running easy_install <path to correct pycharm-debug.egg> (you can find where the egg is on your computer from these instructions). The last thing to do is adding the code to connect to the debug server, pycharm generates it in the configuration windows of the debug server (from the first phase). where to find the code from pycharm

Final Note: I usually surround the two lines in a function that checks for --debug (with argparse) and only then tries to connect to the debug server.

Hope this helps, good luck.

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.