Quickly installing a python package with pip will most likely just make it available in python under your operating system, not LibreOffice. The python docs installing python packages describe pip usage with a warning about using python managed by another package manager (ie LibreOffice).
The python under Windows is a cut-down embedded python version (while most linux distros use their system python) without pip or get-pip.py and there are no supporting python directories in the path. LibreOffice is also installed on Windows with administrator permissions.
Install as follows:
- Download the https://bootstrap.pypa.io/get-pip.py file
- Start a command prompt, preferably with administrator permissions
- Change to the LibreOffice installation directory (eg
cd C:\Program Files\LibreOffice\program
)
- Run
python get-pip.py
- Close command prompt
This will install or upgrade pip for the LibreOffice version of python without affecting the operating system version. Additionally, it will install setuptools and wheel if they’re not installed already.
The installed location depends on the python installation context. For example with python v3.8.10 a WARNING will be displayed that the scripts are installed in 'C:\Program Files\LibreOffice\program\python-core-3.8.10\Scripts' for an administrator install or alternatively, 'C:\Users\User\AppData\Roaming\Python\Python38\Scripts'.
The files installed with pip and the execution is more complicated than it appears. The easiest way to use the right pip for the right python version is to run it from the python install directory using python -m
. This example is a verbose package listing:
C:\Program Files\LibreOffice\program>python -m pip list -v
Package Version Location Installer
---------- ------- ------------------------------------------------------------------------- ---------
pip 22.0.3 c:\program files\libreoffice\program\python-core-3.8.10\lib\site-packages pip
setuptools 60.9.3 c:\program files\libreoffice\program\python-core-3.8.10\lib\site-packages pip
wheel 0.37.1 c:\program files\libreoffice\program\python-core-3.8.10\lib\site-packages pip
To install my-package
change to the LibreOffice installation directory and run:
C:\Program Files\LibreOffice\program>python -m pip install my-package