VS Code cannot resolve OctoPrint classes

Hi,

I can work really fine with VS Code to develop my plugins. But what I do not get up running is using OctoPrint inside my plugin with Intellisense. It cannot resolve the import. Any ideas if I can change it? Debugging and everything else is fine also jumping from my plugin into OctoPrint code.

Cheers,
Nils

Do you have your OctoPrint virtual environment set correctly? At the bottom bar of the screen, there should be a button either showing the currently selected environment, or 'select python environment' (something like that).

The button showing "Select Python Interpreter" every time. I can select one for OctoPrint or the Plugin but it does not change. Also both shows different environments in the list...

Plugin

OctoPrint

Sometimes I have the same issue.
My solution is to create a .vscode/settings.json file in my plugin folder. The settings include the reference to the venv from OctoPrint. After restart of VS Code and reselecting the interpreter, the "Select-Message" in the bottom disappeared

{
    "python.disableInstallationCheck": true,
    "python.defaultInterpreterPath": "/Users/olli/0_Projekte/3DDruck/OctoPrint/octoprint_latest/venv-373-op172/bin/python"    
}

See also: Using Python Environments in Visual Studio Code.

Maybe that helps
Olli

1 Like

I already set this as I found it during my search....but I had a typo in the path. :exploding_head:

Now it works fine. :slight_smile: