I was able to use VS Code as an Editor for Python Macros in LibreOffice Calc. But VS Code doesn’t really integrate as an IDE in that situation, due to the two environments not connecting or merging.
My basic question is How to get VS Code to recognize / integrate into the Python environment that LibreOffice expects to see, and not throw up PyLance errors.
In order to get Python Macros working in LibreOffice, one has to install and figure out one or more extensions related to the pyuno bridge between the UNO objects that the LibreOffice API provides and the Python interpreter being used.
I’m currently using MX-Linux 23 (Debian Bookworm based), Python 3.11.2 (and experimentally 3.13 which I compiled myself ) and LibreOffice 25.2 [previously I had LibreOffice 7.4 running, but upgraded] apologies to Windows users - you’ll have to work that out ..
LibreOffice appears to start up its own Python environment using scripts in the /usr/lib/libreoffice/program directory (in my case /opt/libreoffice25.2/program/) called
pythonloader.py pythonscript.py and perhaps uno.py and unohelper.py
These provide an object called XSCRIPTCONTEXT to the running python interpreter - which in my experience is missing in the startup under VS Code.
I simply don’t know how to get VS Code to initialize this object and consequently stop throwing PyLance errors. I’ve also never used PyLance before and don’t know how it ties into the VS Code ecosystem.
I was working on my 2025 tax return using LibtreOffice and lacked time to go further in my digging, learning and experimenting - but got a macro going that helped me finish on time anyway. As mentioned earlier - VS code did work fine as a plug-in Editor - just useless as an IDE.