pythonlibreoffice

Python vs Libre Office - conflict


I have been struggling with the below issue for 2 weeks and need to ask for your help. What I'm trying to achieve is to run some script in Libre Calc(VB or Python) which would perform some action like selecting, copying ect. and then fire up another script (Python) which would continue using the data from step nr one. The problem is that I keep getting the error message about "SRE module mismatch". From what I know it comes from the conflict between the Libre Office build in Python version (3.9 in my case) and my global Python (3.13). No metter what I do the second script keeps on running in LO Python instead of global one. This is what I have already tried to resolve the conflict.

  1. Made sure my global Python exists in PATH (LO Python is not there).
  2. Tried to run the first code in VB and Python.
  3. Used an intermediary *.but file to run the second code to isolate it from LO.

The second script inherits the LO Python in some magical way.

I tried to use the LO Python and global one to perform all the actions (LO part and the rest) but both Python's are missing some ingredients to do both parts and I wasn't able to fix it.

Thank you for your assistance, Kris.


Solution

  • You are running into a Python environment conflict because LibreOffice Calc uses its own embedded Python interpreter, which can be tricky to work around when trying to also use a global Python interpreter Attempt using IPC ( Inter-Process Communication ). You can separate the two parts entirely by using IPC methods to communicate between the LibreOffice Python and your global Python.