How do I install pip in Libreoffice's embedded Python on Linux? Macro Python

How do I install pip in Libreoffice’s embedded Python on Linux? I wanted to install the pylint package for use in VS Code and display the syntax errors, but I need the pip first.

If I open Module.py in VS Code using system python, the VSCode Explorer Outline tab is blank and pylint doesn’t work in libreoffice macros.

If I open Module.py in VS Code using libreoffice’s built-in python the VSCode Explorer Outline tab displays all the variables and functions of my macro, but I can’t install the pip.

NOTE: If I open Module.py in VS Code using libreoffice’s built-in python and then switch to system python the VSCode Explorer Outline tab displays the variables and functions and pylint works too!

==========

On Winsows 7 x64 I installed Libreoffice portable Version: 6.3.3.2 (x86) in the folder: C:\Portable\LibreOffice

Libreoffice’s built-in python (v3.5.7) executable is: C:\Portable\LibreOffice\App\libreoffice\program\python.exe

I followed this statement: This page has moved - pip documentation v21.2.2

On Windows I was able to install the pip through get-pip.py script: https://bootstrap.pypa.io/get-pip.py

I copied the get-pip.py file to the directory: C:\Portable\LibreOffice\App\libreoffice\program\

and ran the following command from the prompt [cmd.exe]:
C:\Portable\LibreOffice\App\libreoffice\program\python.exe C:\Portable\LibreOffice\App\libreoffice\program\get-pip.py

ready he installed the pip and then installed pylint with this command:
C:/Portable/LibreOffice/App/libreoffice/program/python.exe -m pip install -U pylint --user

My VS Code setup on Windows - ‘settings.json’:

{
  "workbench.colorTheme": "Default Light+",
  "workbench.startupEditor": "newUntitledFile",
  "files.encoding": "windows1252",
  "editor.wordWrap": "on",
  "workbench.colorCustomizations": {
    "terminal.ansiBrightBlue": "#729FCF",
    "terminal.ansiBrightGreen": "#8AE234",
    "terminal.background": "#000000",
    "terminal.foreground": "#D3D7CF",
    "terminal.selectionBackground": "#5cd6933b"
  },
  "workbench.iconTheme": "vscode-icons",
  "python.dataScience.sendSelectionToInteractiveWindow": true,
  "python.linting.enabled": true,
  "python.pythonPath": "C:\\Portable\\LibreOffice\\App\\libreoffice\\program\\python.exe",
  //"python.pythonPath": "C:\\Portable\\LibreOffice\\App\\libreoffice\\program\\python.exe",
  //"python.pythonPath": "C:\\Portable\\Pyhton-3.8.0\\App\\Python\\python.exe",
  //"python.pythonPath": "C:\\Portable\\Pyhton-2.7.17\\App\\Python\\python.exe",
  "editor.formatOnSave": true
}

===========

I tried to use the same logic on Linux, but was unsuccessful:
Linux Mint 19.3 x64 Cinnamon, Libreoffice Version: 6.3.3.2
Note: I have the build-essential package installed: $ sudo apt-get install build-essential

It would be normal to install pip through this command on linux:
$ sudo apt install python3-venv python3-pip

however it installs the pip in system python not Libreoffice’s built-in python.

So I decided to do the same as in Windows:

Libreoffice’s built-in python (v3.5.7) executable is: /opt/libreoffice6.3/program/python

I copied the get-pip.py file to the directory: /opt/libreoffice6.3/program/

and ran the following command on gnome-terminal:

$ sudo su

$ /opt/libreoffice6.3/program/python /opt/libreoffice6.3/program/get-pip.py

and it returns the following error:


Collecting pip
  Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/f9/d3/955738b20d3832dfa3cd3d9b07e29a8162edb480bf988332f5e6e48ca444/setuptools-44.0.0-py2.py3-none-any.whl
Collecting wheel
  Using cached https://files.pythonhosted.org/packages/00/83/b4a77d044e78ad1a45610eb88f745be2fd2c6d658f9798a15e384b7d57c9/wheel-0.33.6-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
ERROR: Exception:
Traceback (most recent call last):
  File "/opt/libreoffice6.3/program/python-core-3.5.7/lib/distutils/sysconfig.py", line 419, in _init_posix
    parse_makefile(filename, g)
  File "/opt/libreoffice6.3/program/python-core-3.5.7/lib/distutils/sysconfig.py", line 288, in parse_makefile
    fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1, errors="surrogateescape")
  File "/opt/libreoffice6.3/program/python-core-3.5.7/lib/distutils/text_file.py", line 100, in __init__
    self.open(filename)
  File "/opt/libreoffice6.3/program/python-core-3.5.7/lib/distutils/text_file.py", line 115, in open
    self.file = io.open(self.filename, 'r', errors=self.errors)
FileNotFoundError: [Errno 2] No such file or directory: '/opt/libreoffice6.3/program/python-core-3.5.7/lib/python3.5/config-3.5m/Makefile'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/tmpvgsl37o3/pip.zip/pip/_internal/cli/base_command.py", line 153, in _main
    status = self.run(options, args)
  File "/tmp/tmpvgsl37o3/pip.zip/pip/_internal/commands/install.py", line 455, in run
    use_user_site=options.use_user_site,
  File "/tmp/tmpvgsl37o3/pip.zip/pip/_internal/req/__init__.py", line 62, in install_given_reqs
    **kwargs
  File "/tmp/tmpvgsl37o3/pip.zip/pip/_internal/req/req_install.py", line 861, in install
    use_user_site=use_user_site, pycompile=pycompile,
  File "/tmp/tmpvgsl37o3/pip.zip/pip/_internal/req/req_install.py", line 495, in move_wheel_files
    warn_script_location=warn_script_location,
  File "/tmp/tmpvgsl37o3/pip.zip/pip/_internal/wheel.py", line 355, in move_wheel_files
    prefix=prefix,
  File "/tmp/tmpvgsl37o3/pip.zip/pip/_internal/locations.py", line 125, in distutils_scheme
    i.finalize_options()
  File "/opt/libreoffice6.3/program/python-core-3.5.7/lib/distutils/command/install.py", line 283, in finalize_options
    (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
  File "/opt/libreoffice6.3/program/python-core-3.5.7/lib/distutils/sysconfig.py", line 482, in get_config_vars
    func()
  File "/opt/libreoffice6.3/program/python-core-3.5.7/lib/distutils/sysconfig.py", line 425, in _init_posix
    raise DistutilsPlatformError(my_msg)
distutils.errors.DistutilsPlatformError: invalid Python installation: unable to open /opt/libreoffice6.3/program/python-core-3.5.7/lib/python3.5/config-3.5m/Makefile (No such file or directory)

Can anybody help me!
Thanks!

My VS Code setup on Linux - ‘settings.json’:

{
  "workbench.colorTheme": "Default Light+",
  "workbench.startupEditor": "newUntitledFile",
  "files.encoding": "windows1252",
  "editor.wordWrap": "on",
  "workbench.colorCustomizations": {
    "terminal.ansiBrightBlue": "#729FCF",
    "terminal.ansiBrightGreen": "#8AE234",
    "terminal.background": "#000000",
    "terminal.foreground": "#D3D7CF",
    "terminal.selectionBackground": "#5cd6933b"
  },
  "workbench.iconTheme": "vscode-icons",
  "python.dataScience.sendSelectionToInteractiveWindow": true,
  "python.linting.enabled": true,
  "python.pythonPath": "/opt/libreoffice6.3/program/python",
  //"python.pythonPath": "/usr/bin/python3",
  //"python.pythonPath": "/opt/libreoffice6.3/program/python",
  "editor.formatOnSave": true
}

ZazPip Extension, manages and installs pip packages in libreoffice:

Video Tutorial:
https://vimeo.com/369488703

https://streamable.com/n1rc9d

1 Like


It did not work for me!!

As you told in another thread you are on Ubuntu, it should not be necessary. IMHO Linux uses system installed python by default. So this extension solves a problem in the Windows versions.
.
2 other remarks: Don’t append to old questions, if not necessary (just think twice before you do). Prefer to open a new topic, where you can provide a link to the older topic.
And always give some details of OS and LO-Versions.

Correct !
AFAIK Zaz-pip should only be used under Windows.

If not present pip can be installed downloading standard PIP installer as per Installation - pip documentation v23.2 instructions

OK, thanks for the heads up!

This is correct for the distributed version of LibreOffice which is compiled with the same toolset as the distributed Python runtime.
The “community version” downloaded from libreoffice.org comes with its own Python runtime, both compiled with the same toolset.