Bug 118503 - Can't run user python macros.
Summary: Can't run user python macros.
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.0.4.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-Python
  Show dependency treegraph
 
Reported: 2018-07-02 13:19 UTC by Luis
Modified: 2020-08-25 13:35 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 Luis 2018-07-02 13:19:33 UTC
Description:
Python macros stored in user profile can't be run.

Steps to Reproduce:
1. Copy sample python script file "HelloWorld.py" from directory share of LO instalation to directory Script/python/ on user profile.
2. Open a new text document.
3. Try to run copied python macro ("HelloWorldPyton") from user location.

Actual Results:
An error message appears:

pyuno._createUnoStructHelper: member 'Context' of struct type 'com.sun.star.uno.Exception' not given a value.


Expected Results:
Inserted text "Hello World (in Python)" in document.


Reproducible: Always


User Profile Reset: Yes



Additional Info:
Tested in windows 7

Versión: 6.0.4.2
Id. de compilación: 9b0d9b32d5dcda91d2f1a96dc04c645c450872bf
Subprocs. CPU: 2; SO: Windows 6.1; Repres. IU: predet.; 
Configuración regional: es-ES (es_ES); Calc: group
Comment 1 Buovjaga 2018-07-15 13:52:32 UTC
No problem for me on Windows or Linux. Tried 6.0.4 and master.
Directory name should be Scripts/python and not Script/python. Then the scripts appear in My Macros.
Comment 2 raal 2018-07-16 21:20:20 UTC
I can confirm with Version: 6.2.0.0.alpha0+ (x64)
Build ID: 7e8dbbb02f25278d5afc51ae4a397831f5b21239
CPU threads: 1; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-07-15_02:52:05

path C:\Users\user\AppData\Roaming\LibreOfficeDev\4\user\scripts\python
Comment 3 Xisco Faulí 2018-07-17 19:24:03 UTC
@raal, any chance you could try this with previous versions of LibreOffice ?
Comment 4 Luis 2018-07-24 13:47:12 UTC
If case of directory name is not exactly "Scripts/python" (S in uppercase and rest in lowercase) then the python scripts are displayed correctly (files and functions) but don't run and appears the indicated error message.

In my working environment (Windows 7 with PCs conected to domain) the user profile is stored in D: drive so user python scripts are stored in

D:\Usuarios\nombre_usuario\AppData\Roaming\LibreOffice\4\user\Scripts\python

Tested with local user and profile stored in C: drive the issue is not present.
Comment 5 Alain Romedenne 2020-04-24 14:45:40 UTC
Hi Luis, 

Please provide us with the output of the following commands in the Python shell:

import sys
sys.path

HINT
Running the Python interactive console: 
https://help.libreoffice.org/6.4/en-US/text/sbasic/python/python_shell.html
Comment 6 Luis 2020-04-24 21:00:27 UTC
Hi Alain

I am currently working at home. I can't provide the requested information from my corporate environment.
When I can resume work in my office, I will post the information.
Comment 7 Luis 2020-06-30 13:14:08 UTC
Hi Alain:

Test done in my working environment (now windows 10) with recent development version 7.1.0.0.alpha0+ (x86)

Version: 7.1.0.0.alpha0+ (x86)
Build ID: 8ed11b7289533bd609fbcb2adfb7b2982ef6fe22
CPU threads: 4; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: es-ES (es_ES); UI: en-US
Calc: CL

In this versión if case of directory name is not exactly "Scripts/python" then the python scripts are displayed correctly (files and functions) but the run button is disabled.

The results of the python shell are:

Python 3.7.7 (heads/master-dirty:8ed11b728953, Jun 28 2020, 02:29:02) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'D:\\LO7\\program', 'D:\\LO7\\program\\python-core-3.7.7\\lib', 'D:\\LO7\\program\\python-core-3.7.7\\lib\\site-packages', 'D:\\LO7\\program\\python37.zip', 'D:\\LO7\\program\\python-core-3.7.7\\DLLs', 'D:\\LO7\\program\\python-core-3.7.7\\bin', 'D:\\LO7\\program\\python-core-3.7.7']
>>>
Comment 8 Alain Romedenne 2020-08-25 13:35:28 UTC
<UserProfile>/Scripts/python should be appended to Python sys.path in this context