[Python] How can import package-numpy for libreoffice's macro to call python?

Discussão em 'Python' iniciado por Stack, Fevereiro 6, 2025.

  1. Stack

    Stack Membro Participativo

    "numpy" is installed in for libreoffice24.8:

    ls /opt/libreoffice24.8/program | grep numpy
    numpy
    numpy-2.2.2.dist-info
    numpy.libs


    Edit a test python script for macro in libreoffice24.8 to call:

    vim .config/libreoffice/4/user/Scripts/python/test.py
    def output_screen():
    import numpy as np
    print("call python in macro")


    Run it in macro:

    [​IMG]

    How can import package-numpy for libreoffice's macro to call python?
    I install numpy for libreoffice this way:

    sudo python3 -m pip install numpy --target=/opt/libreoffice24.8/program


    Remove all of them and try again:

    sudo rm -rf /opt/libreoffice24.8/program/numpy*


    [​IMG]

    Show numpy location:

    pip show numpy
    Name: numpy
    Version: 1.24.2
    Summary: Fundamental package for array computing in Python
    Home-page: https://www.numpy.org
    Author: Travis E. Oliphant et al.
    Author-email:
    License: BSD-3-Clause
    Location: /usr/lib/python3/dist-packages
    Requires:
    Required-by: pandas, rank-bm25


    How can make libreoffice refer to the path when to call python script in macro?

    Continue reading...

Compartilhe esta Página