PyCharm remote debugging

I have created a plugin for OctoPrint. I do however have some install problems and need to debug it running on my Raspberry Pi since it is depending on the Raspberry Pi hardware.

I have found the following instructions on the web:

They however shows how to debug one Python file and not Octoprint with a plugin so I need some advise on how to apply these instructions on OctoPi.

Is there an SFTP server already installed on OctoPi or do I need to install one?
Can I debug the already installed Octoprint and plugin or do I need to setup a different instance for debugging?

Are you using PyCharm Professional, or community edition? You can't do it on community. Try VSCode Remote SSH or something.

I use Pycharm remote via SSH, and it is quite easy. Set as project interpreter, map the paths for deployment then it is done. Debugging can be done by switching from 'script' to 'module' to run OctoPrint, rather than a file.

I have installed PyCharm Professional.

(I got passed my first connection problem by restarting PyCharm.)

I have Octoprint loaded as one project in PyCharm and my plugin as a second project using the same venv. Seems to work OK.

I have setup the mapping for OctoPrint like this:
Local Path: C:\Users\Lars\PycharmProjects\OctoPrint
Deployment Path: /OctoPrint
Web Path: /

But I am getting a warning complaining about the mapping for my plugin project. How shall this be mapped.

I am also getting an error message at startup: Couldn't refresh skeletons for remote interpreter: Can't get remote credentials for deployment server pi@
When I click Test connection in my setup it now says "Successfully connected ..."

I may have messed up something since I have tried some different settings, but I don't know what I may have done wrong.

Have you setup a remote interpreter (venv)? That was what I had to do, and it did the rest for me.
Add it here:

Then I configured the interpreter to be /home/oprint/bin/python, and the path mapping below it from Project root -> /home/pi/OctoPrint-WS281x_LED_Status

Then once it has synced, SSH to the Pi and install the plugin there (eg. cd /home/pi/OctoPrint-WS281x_LED_Status, then source ~/oprint/bin/activate, then pip install -e .)

As for run/debug, I have it looking like this, module name octoprint and the correct interpreter:

Yes I have, but there is someting wrong with it.

I have now removed it, created a new one, restarted PyCharm a lot of times in different order and made a lot of tests on different settings.

I am not sure I understand your instructions correctley. Here is what I have done:

I start with creating my server configuration

I insert my password on the next dialough and click next

The next dialouge will show some deafult values
If I use these my venv will be installed in /tmp/pycharm_project_596 i.e in the disk root (not in Project root).
...but if I change Sync folder as follows:
and click finnish I will see:

and when I click OK my venv will be uploaded to /home/pi/tmp/pycharm_project_596
If I look at the new connection configuration it was created as follows:
Root path: /
Web server URL: to http:///.

I changed the URL to:

I also tried to setup the debug as you suggested which givs me the following Run msg:

sh://pi@ -u -m OctoPrint serve --debug
/usr/bin/python: No module named OctoPrint

Process finished with exit code 1

If I try my old setting using the Octoprint run script I will get the following run msg:

ssh://pi@ -u /home/pi/tmp/pycharm_project_596/run serve
fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File "/home/pi/tmp/pycharm_project_596/run", line 26, in
File "/home/pi/tmp/pycharm_project_596/src/octoprint/", line 625, in main
from octoprint.util.fixes import patch_sarge_async_on_py2
File "/home/pi/tmp/pycharm_project_596/src/octoprint/util/", line 15, in
import past.builtins
ImportError: No module named past.builtins

Process finished with exit code 1

How can I fix this?

Sorry, my screenshot didn't show the correct path to the virtual environment, you need to change that too. And I think you are confused about the difference between a virtual environment and your project.

  • On your Pi running OctoPi, there is a venv under /home/pi/oprint, or if you installed it manually wherever it is.
  • The server mapping is not your venv - it is the code for your project. You can't sync your windows venv with the raspberry Pi, you create a new one there.

This section doesn't really matter, unless you plan on writing tests or something that hit the OctoPrint webserver, don't worry about it.

I think you are most of the way there, just need to correctly define the OctoPrint venv, on your Raspberry Pi.

Thank you very much.

So I am just setting up a link to the already installed interpreter. I have now done that and can now see its list of installed libraries including my plugin which I have already intalled on the Pi.

<Project root> - /home/pi/tmp/pycharm_project_596
... mean that the project on my laptop <Project root>
is mapped to /home/pi/tmp/pycharm_project_596
on the Pi.

I missunderstood this and thougt it was one link
<Project root>/home/pi/tmp/pycharm_project_596
which confused me.

The problem I have is that my plugin do not show up in Plugin Manager after a succesfull installation. so I thougt I could see whats wrong by running it in debug mode.

I have now started Octoprint in debug mode and the following is printed to the console:

ssh://pi@ -u /home/pi/.pycharm_helpers/pydev/ --module --multiproc --qt-support=auto --client --port 35495 --file octoprint serve --debug
pydev debugger: process 3598 is connecting
Connected to pydev debugger (build 202.8194.15)
fatal: not a git repository (or any of the parent directories): .git
2020-11-30 14:53:50,627 - octoprint.startup - INFO - ******************************************************************************
2020-11-30 14:53:50,632 - octoprint.startup - INFO - Starting OctoPrint 0+unknown
2020-11-30 14:53:50,634 - octoprint.startup - INFO - ******************************************************************************

The fatal error looks serious. What does it mean?
What is not a git repositiory?

After changing the portnumber to 5001 (to avoid conflict with my standard installation of OctoPrint) I could run OcttoPrint in debug mode without any execeptions thrown, even though it was started in safe mode.
I could open Plugin Manager and there my plugin Octoprint-Brightpi showed up in the list.

The second (and third, after updating to 1.5.0) time I started Octoprint in debug mode I'm getting a lot of errors like this:

2020-12-01 09:42:18,375 - octoprint.server.util.flask.fix_webassets_filtertool - ERROR - Got an exception while trying to apply filter, ignoring file
Traceback (most recent call last):
File "/home/pi/tmp/pycharm_project_596/src/octoprint/server/util/", line 232, in fixed_wrap_cache
content = func().getvalue()
File "/home/pi/oprint/lib/python3.7/site-packages/webassets/", line 250, in func
data = StringIO(
File "/home/pi/oprint/lib/python3.7/site-packages/webassets/", line 78, in data
f = open(self.filename, 'r', encoding='utf-8')
FileNotFoundError: [Errno 2] No such file or directory: '/home/pi/oprint/lib/python3.7/site-packages/octoprint/static/js/lib/jquery/jquery.ui.core.js'

It complains about not finding jquery.ui.core.js (which do not exist on my Pi).
My question is now where should that file reside in the project and how are the files assembeled on my Raspberry Pi disk?

The venv contains /lib/site-packages but there is no octoprint folder in there.
In the OctoPrint src there is a file structure
octoprint/static/js/lib/jquery/<some_files> which match the part after site-packages in the path to the missing file.

If I look in this directory which I have cloned from the OctoPrint repository there is no jquery.ui.core.js so where should this file come from or what is actually wrong with my project?

Now I am a bit confused.

When I run my normal instance of OctoPrint on my Raspberry Pi and start debugging, shouldn't that start a new instance of the server?

I have setup the normal instance to respond to default port 5000
and my debug instance to respond to port 5001

There seems to be some conflict between the two.
When I have started the debug instance (with errors, see previous post) and try to contact the servers they will both respond with the following message:

Connecting to OctoPrint's server...

If I access the normal server before I start the debugger, the normal instance works without problems (or I just had bed luck first time).

Another "strange" thing is that both instances are running the same plugins installed on the normal instance.

If I stop the normal instance I cannot run the debug instance. I am getting the following error:

13:08 Error running 'Octoprint server': Python helpers are not copied yet to the remote host. Please wait until remote interpreter initialization finishes.

13:08 Couldn't upload helpers for remote interpreter: Connection timed out: connect

Can I change my setup in some way to fix this problem?