Bug 143832 - Can not generate pycache (.pyc) files on Windows as non-admin accounts
Summary: Can not generate pycache (.pyc) files on Windows as non-admin accounts
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Installation (show other bugs)
Version:
(earliest affected)
7.0.6.2 release
Hardware: All Windows (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-Python
  Show dependency treegraph
 
Reported: 2021-08-12 09:00 UTC by Ming Hua
Modified: 2025-06-20 10:19 UTC (History)
1 user (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 Ming Hua 2021-08-12 09:00:14 UTC
Description:
It seems that the way current Windows MSI installer is set up, if LibreOffice is installed by an admin account to the default place (C:\Program Files\LibreOffice), a non-admin account can use the application perfectly fine, including Python scripting features, but the bundled Python can not generate the .pyc pycache files because the non-admin account doesn't have write permission for C:\Program Files\LibreOffice\program directory.

Presumably this will cause LibreOffice compiling to bytecode each time Python is used, and affect performance for heavy Python-scripting users.

Steps to reproduce:
1. Install LibreOffice on Windows using the MSI installer, either from an account with admin privileges, or from an ordinary account and provide password for admin when asked.  Use the default installation directory "C:\Program Files\LibreOffice", but anywhere else that ordinary users don't have write access should also be OK.

2. Do NOT start LibreOffice from the admin account.

3. Start LibreOffice from the ordinary non-admin account, run some Python sample macros that came with the installation.  Optionally one can also try some Python commands and macros from command line using the bundled Python.

4. Observe that no matter how Python is used, the directory supposed to store pycache files "C:\Program Files\LibreOffice\program\__pycache__" and "C:\Program Files\LibreOffice\program\python-core-<version>\lib\__pycache__" are not created, and the .pyc files are not generated.

Expected result:
Generate pycache files for non-admin account, somewhere in user profile, maybe?  Or alternatively the installation process can generate them as admin account?

Additional Information:
This is hard to test with parallel installation, so I only get this for my main 7.0.6 installation:
Version: 7.0.6.2 (x64)
Build ID: 144abb84a525d8e30c9dbbefa69cbbf2d8d4ae3b
CPU threads: 2; OS: Windows 10.0 Build 19043; UI render: default; VCL: win
Locale: zh-CN (zh_CN); UI: en-US
Calc: threaded
...but I don't think this has changed for 7.2 or master.
Comment 1 Xisco Faulí 2025-06-05 11:33:28 UTC
Thank you for reporting the bug.
Could you please try to reproduce it with the latest version of LibreOffice from https://www.libreoffice.org/download/libreoffice-fresh/ ?
I have set the bug's status to 'NEEDINFO'. Please change it back to 'UNCONFIRMED' if the bug is still present in the latest version.
Comment 2 Ming Hua 2025-06-14 09:47:04 UTC
(In reply to Xisco Faulí from comment #1)
> Could you please try to reproduce it with the latest version of LibreOffice
> from https://www.libreoffice.org/download/libreoffice-fresh/ ?

Sure, I've recently upgraded my main LO installation (in C:\Program Files\) to version 25.2.4 with Python 3.10.18:

Version: 25.2.4.3 (X86_64) / LibreOffice Community
Build ID: 33e196637044ead23f5c3226cde09b47731f7e27
CPU threads: 12; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Raster; VCL: win
Locale: zh-CN (zh_CN); UI: en-US
Calc: CL threaded

And this bug is still reproducible. I'll have to manually generate those pycache files.
Comment 3 Xisco Faulí 2025-06-16 10:42:26 UTC
My take on it: https://gerrit.libreoffice.org/c/core/+/186558
Comment 4 Xisco Faulí 2025-06-20 10:19:59 UTC
(In reply to Xisco Faulí from comment #3)
> My take on it: https://gerrit.libreoffice.org/c/core/+/186558

I don't think this is the right solution. it needs more investigation...