(2024-03-15, 19:34)iceman20k Wrote: Hi there.
I am trying to use VS Code for Kodi addon development, just started. VS code tells me of course it cant find the python libs "import xbmc" etc., i know i cant execute where i develop, i code directly in the addons folder where kodi runs, but can i get "rid" of these messages and get the python libs into VS Code on my desktop?
Thanks for any advice.
Setup a python "virtual environment" using venv. I don't do it in VS Code. I have python 3.8 installed on my system. I run venv from a command prompt using Python 3.8 and have a folder tree with various subfolders per venv. But I am also lazy and sometimes will just tell VS code to use my python 3.8 environment. Either way I use pip to get kodi stubs from pypi for either a venv or my main python 3.8.
Then in vs code you can set your python to your venv or python 3.8 and import xbmc, xbmcgui etc. Kodi stubs has full docstrings that vs code will show.
Also suggest creating a .env file with a PYTHONPATH variable set for all the script.modules needed (you can run your script in Kodi with debugging and Kodi will log the sys.path for your addon which you can copy into your .env).
As far as debugging, I have to admit I have not figured out how to correctly set up remote debugging for an addon running within a local Kodi process in Windows. When my addon starts it pauses waiting for a connection but I'm never able to get the debugger to actually connect and it times out.
I also use github desktop. Set up a folder script.myscript that has .gitignore, .vscode, .env etc and a subfolder script.myscript with the actual code. VS code can do git, but I haven't explored that as using github desktop seems more powerful.
scott s.
.