Bug 144224 - Create a setup dialog to choose which Python interpreter to use
Summary: Create a setup dialog to choose which Python interpreter to use
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-Python
  Show dependency treegraph
 
Reported: 2021-08-31 18:04 UTC by Rafael Lima
Modified: 2023-08-26 12:16 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2021-08-31 18:04:05 UTC
LibreOffice comes with a bundled Python that has a limited set of packages and it is not possible to install additional packages as numpy, pandas or other popular packages (see 143980 and 143867).

One not-so-complicated way to solve this issue would be to create a new dialog in "Tools - Options" so the user can choose which Python interpreter to use. This way the user can install another Python interpreter and add whatever packages he/she needs.

The idea would be to create a new dialog similar to the one we currently have for JRE in Tools - Options - Advanced. The user could then select the base path for the python interpreter that will be used by LO. By default it can be the one bundled in LO's installation, but advanced users will be able to choose a different one and set it up as they wish.

This idea was inspired by the fact that on Ubuntu, if you install LibreOffice from their PPA it will not come with the bundled Python shipped with LO. Instead it will use system-wide Python and any packages installed will work in Python scripts launched from within LO (see 143980 comment #7).
Comment 1 Roman Kuznetsov 2021-08-31 19:15:53 UTC
Thanks Rafael. I think it's a brilliant idea and it can help many people to use python scripts instead our old StarBasic
Comment 2 edil 2021-08-31 20:16:17 UTC
Thanks Rafael. Also I think it's a brilliant idea to choose the python interpreter that will be used by LO. More simpler will be the use of Python, LO will be very faster e powerful.
A normal user of my App isn't able to use PIP, while install Python is more simpler, like install LO.
Comment 3 Heiko Tietze 2021-09-01 08:48:11 UTC
Not much to add from UX POV. New "Python options" goes to LibreOffice > Advanced with a list similar to "Java Options" but without the use it checkbox and the interaction buttons. The list should offer all Python interpreters (location might be shown per tooltip).
Comment 4 flywire 2021-09-01 13:03:50 UTC
(In reply to Rafael Lima from comment #0)
> LibreOffice comes with a bundled Python that has a limited set of packages
> and it is not possible to install additional packages as numpy, pandas or
> other popular packages (see 143980 and 143867).
 
*WRONG* - see https://ask.libreoffice.org/t/install-python-package-for-libre-office/66934/15 - Installs scipy and numpy.

The big issue is Python needs pip to install packages but it is not implemented in LO and the community is fairly clueless how to install it - see Bug #143867

Clearly the community has little idea how to do it - https://ask.libreoffice.org/t/install-python-package-for-libre-office/66934 Even there the dll is missing. Someone muddling through the process and installing pip and packages doesn't mean everything is fine.

A better solution is better support of the existing embedded Python, including pip.

> One not-so-complicated way to solve this issue would be to create a new
> dialog in "Tools - Options" so the user can choose which Python interpreter
> to use. This way the user can install another Python interpreter and add
> whatever packages he/she needs.
 
Each version of LO has a known embedded version of Python, a big advantage. That's not the case with a user's system python. I wouldn't support this configuration to replace the standard install.

Installing embedded LO python in a Virtual Environment is well worth considering.
Comment 5 Michael Stahl (allotropia) 2021-09-02 14:42:25 UTC
this cannot possibly work, the python shared libraries do not have a stable ABI and the pyuno library depends on that

in contrast, the JVM does have a stable ABI, so you can select any one that's at least the minimal version
Comment 6 Stephan Bergmann 2021-09-02 15:04:21 UTC
(In reply to Rafael Lima from comment #0)
> This idea was inspired by the fact that on Ubuntu, if you install
> LibreOffice from their PPA it will not come with the bundled Python shipped
> with LO. Instead it will use system-wide Python and any packages installed
> will work in Python scripts launched from within LO (see 143980 comment #7).

(In reply to Michael Stahl (allotropia) from comment #5)
> this cannot possibly work, the python shared libraries do not have a stable
> ABI and the pyuno library depends on that

Also note that the python executable in the LibreOffice program directory is actually a wrapper (a shell script on Linux and macOS, see pyuno/CustomTarget_python_shell.mk; an .exe on Windows, see pyuno/Executable_python.mk) that is careful to set up an environment in which LibreOffice's PyUNO also works for stand-alone Python programs.  Linux distributions that do not include that wrapper but use the distro's python executable directly typically make sure to set up that environment, too, in a different way.