Import error octoprint.plugin


#1

What is the problem?
I am trying to write a new plugin for OctoPi on raspberry pi like in this tutorial: http://docs.octoprint.org/en/master/plugins/gettingstarted.html . I have already installed eclipse with pydev package for remote development of python scripts using ssh. After debugging or running of a script I become an error ImportError: no module named octoprint.plugin. I have also tried directly on a raspberrry pi, using python idle and thonny and they are also showing this error.

What did you already try to solve it?
I think it is because of python interpreter or sys.path maybe or maybe not. I am not a real programmer and learning to write python scripts.
If you have another ideas about debugging, it will be nice if you will share them with me. I just want to see if I will become some mistakes while writing a script.

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)
OctoPrint version: 1.3.9
OctoPi version 0.15.1


#2

How are you installing the plugin? ...Are you installing one? Or are you just running it directly from the plugin directory? Which part of the guide are you up to? (the first part just has you run it directly from a manually "installed" file, while later it gives you details on how to create an automatically installable plugin, which bit are you on now?)

Also, have you activated the virtual environment that octoprint runs in? Octoprint doesn't run in the system installed python, but rather in a virtual environment.

I've never tried to remotely develop using idle or eclipse so can't really help there (I do all my shenanigans in a VM on my pc).


#3

thank your for your answer!

I am installing the plugin by cloning from github OctoPrint-PluginSkeleton to have just a skelet and then initialize it (give access to OctoPrint) by python setup.py install in the folder of this plugin. After I manually start the server in venv of raspberry oprint, it is running egg_info and loading plugin. Everything works perfect, i can also see the plugin in web interface. I am at that point, where is talking about, how to make parts of plugin user adjustable.
i think i had installed it correct, because it works:)
i have also debugged it directly in python idle on raspberry, but it shows also error.

how have you controlled if you have any mistakes in your plugin?


#4

octoprint plugins only work in octoprint, if you try to run the code in just regular python, they obviously won't work there.

I'm a bit confused, you said you have errors, but the plugin works. Where are you seeing the error? Is it in octoprint's log? Are you trying to just run python code outside of octoprint? Or is the plugin only showing errors after you've modified it? Perhaps posting your modified plugin might help (hosted on github or something).