Search code examples
pythonmacroslibreoffice

How to execute a python macro that launches another python script?


I want to create a python macro on libreoffice which will trigger another python script. Unfortunately it doesn't work and I don't know why.

When I launch the python from terminal it works fine but not from macro.

My macro.py file :

import os

def launch():
        os.system("python /home/ivq/Documents/generation.py")
launch()

Expected result : launch generation.py
Actual result : nothing happen


Solution

  • import subprocess
    
    subprocess.call(["python", "/home/ivq/Documents/generation.py"])
    

    Should help?