Bug 33355 - Python scripting not available
Summary: Python scripting not available
Status: CLOSED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
3.3.0 RC4
Hardware: x86 (IA32) Windows (All)
: high major
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 32329 (view as bug list)
Depends on:
Blocks: 32894 mab3.4
  Show dependency treegraph
 
Reported: 2011-01-21 14:27 UTC by clio
Modified: 2011-05-20 03:36 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments
extension that can't register the Python script on Windows (47.86 KB, application/vnd.openofficeorg.extension)
2011-01-21 14:27 UTC, clio
Details
Error messages (Linguist / TradutorOOoText / OO.o Live Word Count) (23.33 KB, image/png)
2011-01-24 02:44 UTC, manj_k
Details
Screenshot "error_ExtExample" (34.05 KB, image/png)
2011-04-21 01:52 UTC, manj_k
Details
Comparison 1: Screenshots "tools_macros_run_libo340b2.png" (20.39 KB, image/png)
2011-04-21 01:54 UTC, manj_k
Details
Comparison 2: Screenshot "tools_macros_run_libo332.png" (LibO 3.3.2) (22.35 KB, image/png)
2011-04-21 01:57 UTC, manj_k
Details
Screenshot: Hello World... (21.50 KB, image/png)
2011-05-16 10:25 UTC, manj_k
Details

Note You need to log in before you can comment on or make changes to this bug.
Description clio 2011-01-21 14:27:44 UTC
Created attachment 42291 [details]
extension that can't register the Python script on Windows

The Python scripts list is empty and the extension installation (in the attachment) ends with error on Windows XP and Windows 7 due to the Python script can't be registered. (The extension is for Writer and resides in Tools/Add-ons menu, it can test Java, JavaScript, Python and Basic scripts, it is extracted from here: http://wiki.services.openoffice.org/wiki/Extensions_Packager#A_sophisticated_extension)
Comment 1 manj_k 2011-01-21 17:44:11 UTC
CC
Comment 2 hanya 2011-01-22 19:14:53 UTC
I can reproduce the problem on WinXP and LOrc4, any python scripts are not shown in the script organizer of Python.

It seems this problem is based on implementation loader for Python. The script provider for python depends on it.
I tried to execute the following basic code to make new instance of css.loader.Python: 

Sub Main
  CreateUnoService("com.sun.star.loader.Python")
End Sub

I got the following error:

Type: com.sun.star.uno.RuntimeException
Message: python-loader:<type 'exceptions.ImportError'>: No module named pythonloader.
traceback follows
no traceback available.
Comment 3 manj_k 2011-01-24 02:39:44 UTC
[LibO 3.3.0 RC4 on WinXP]

The same issue with the following Python extensions/scripts:

(1) Linguist 1.5 (.oxt)
<http://extensions.services.openoffice.org/en/project/Linguist>

(2) TradutorOOoText 1.0.0 (.oxt)
<http://extensions.services.openoffice.org/en/project/TradutorOOoText>

(3) OO.o Live Word Count (wc.py)
<https://bitbucket.org/yawaramin/oo.o-live-word-count/src/940baeb4fcc2/>

The extensions/scripts don't work, and I get the attached error messages.
(Works fine with OOo 3.3.0 RC10.)
Comment 4 manj_k 2011-01-24 02:44:18 UTC
Created attachment 42357 [details]
Error messages (Linguist / TradutorOOoText / OO.o Live Word Count)

Error messages (Linguist / TradutorOOoText / OO.o Live Word Count)
Comment 5 Olivier R. 2011-01-24 04:36:30 UTC
Bug reproduced on Windows 7 also.

Imho, this bug is a *blocker*.
Comment 6 Noel Power 2011-01-24 12:41:53 UTC
confirmed with xp with rc4 for me too -> tor
Comment 7 Yakov 2011-01-24 20:54:29 UTC
Bug reproduced on Windows Vista too.
It can be quick fixed:
Simply copy pythonloader.uno.dll 
from OOo3.1 to LibreOffice directory Basis/Program.
Comment 8 manj_k 2011-01-25 01:27:30 UTC
Yep, a nice workaround. :)
With <pythonloader.uno.dll> from OOo 3.3 RC10--copied to LibO 3.3 RC4--my issues were fixed (s. comment #3), and the Python scripts list is perfect.
Comment 9 Don't use this account, use tml@iki.fi 2011-01-25 02:14:31 UTC
When I try to install the extension in the initial comment, I get an error dialog titled "Extension Manager" that says "Failed to register package for vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages/.... I don't understand.
Comment 10 Matthias 2011-01-25 03:00:46 UTC
(In reply to comment #9)
> When I try to install the extension in the initial comment, I get an error
> dialog titled "Extension Manager" that says "Failed to register package for
> vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages/.... I don't
> understand.

This is a subsequent error of the LibO python loader not working. Comment #2 is a more direct way of reproducing this.

However, I can confirm the workaround in comment #7 works. The extension can then be installed successfully.
Comment 11 Don't use this account, use tml@iki.fi 2011-01-25 03:10:42 UTC
BTW, no need to copy the pythonloader.uno.dll from some old OOo version, just copy if from Basis\program in the LibreOffice installation.

It might even work to *move* it, investigating.

Comment #2 indeed looks much more useful for debugging this.
Comment 12 Don't use this account, use tml@iki.fi 2011-01-25 03:13:23 UTC
Ah, I wrote the last comment before actually checking; even if I copy pythonloader.uno.dll from Basis\program to program, I can't install the ExtExample-1.0.1.oxt, I get the same error message.
Comment 13 Don't use this account, use tml@iki.fi 2011-01-25 06:29:03 UTC
Suggested fix:

commit 8dfc7cf7a1967d1313826651dbcdf1c46a03779f
Author: Tor Lillqvist <tlillqvist@novell.com>
Date:   Tue Jan 25 16:24:07 2011 +0200

    Manipulate also the C runtime's environment
    
    Fixes fdo#33355.

diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx
index 796f4c4..1749b8e 100644
--- a/sal/osl/w32/process.cxx
+++ b/sal/osl/w32/process.cxx
@@ -28,6 +28,7 @@
 
 #define UNICODE
 #include "system.h"
+#include <string.h>
 #ifdef _MSC_VER
 #pragma warning(push,1) /* disable warnings within system headers */
 #endif
@@ -419,7 +420,15 @@ oslProcessError SAL_CALL osl_setEnvironment(rtl_uString *ustrVar, rtl_uString *u
     LPCWSTR lpName = reinterpret_cast<LPCWSTR>(ustrVar->buffer);
     LPCWSTR lpValue = reinterpret_cast<LPCWSTR>(ustrValue->buffer);
     if (SetEnvironmentVariableW(lpName, lpValue))
+    {
+        wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + wcslen(lpValue) + 1];
+        wcscpy(buffer, lpName);
+        wcscat(buffer, L"=");
+        wcscat(buffer, lpValue);
+        _wputenv(buffer);
+        delete[] buffer;
         return osl_Process_E_None;
+    }
     return osl_Process_E_Unknown;
 }
 
@@ -429,7 +438,14 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString *ustrVar)
     //process's environment.
     LPCWSTR lpName = reinterpret_cast<LPCWSTR>(ustrVar->buffer);
     if (SetEnvironmentVariableW(lpName, NULL))
+    {
+        wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + 1];
+        wcscpy(buffer, lpName);
+        wcscat(buffer, L"=");
+        _wputenv(buffer);
+        delete[] buffer;
         return osl_Process_E_None;
+    }
     return osl_Process_E_Unknown;
 }
Comment 14 Don't use this account, use tml@iki.fi 2011-01-25 06:36:51 UTC
Approved by Fridrich, committed to master and libreoffice-3-3. Will thus be in 3.3.1.
Comment 15 jeff 2011-01-31 00:51:54 UTC
I confirm with numbertext's extension (http://numbertext.org/), and workaround in comment#7 don't work...
Comment 16 Cédric Bosdonnat 2011-02-08 07:25:12 UTC
*** Bug 32329 has been marked as a duplicate of this bug. ***
Comment 17 Rainer Bielefeld Retired 2011-02-11 06:48:43 UTC
Bug 32329 - [MAILMERGE] E-Mail server connection fails
Verified with "LibreOffice 3.3.1 RC1 - WIN7  Home Premium (64bit) German UI  [OOO330m19 (build 7 / tag 3.3.1.1)]", works fine now.
Comment 18 Gouchi 2011-02-21 02:46:27 UTC
I confirm I can use Python extensions and see python scripts with LO 3.3.1 RC 2 on WinXP :
LibreOffice 3.3.1 
OOO330m19 (Build:8)
tag libreoffice-3.3.1.2
Comment 19 Caolán McNamara 2011-03-07 08:06:32 UTC
There's another different MacOSX bug (bug #34699) which has a similar looking effect, but is triggered with python 2.3 as apparently used on that platform.
Comment 20 manj_k 2011-04-21 01:51:14 UTC
That issue occurs again with 
libo_3.4.0beta2_win_x86_install_multi.exe
LibreOffice 3.4.0 Beta 2 [daily - current - 20-Apr-2011 13:46]
[on WinXP]

(1) ExtExample-1.0.1.oxt (attached extension id=422921)
"Failed to register package for
vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE/uno_packages/..."
[see attached screenshot "error_ExtExample"]

(2) Tools > Macros > Run > LibreOffice Macros > HelloWorld
Missing "HelloWorldPython"
[see attached screenshots "tools_macros_run_libo340b2.png"
and "tools_macros_run_libo332.png"]
Comment 21 manj_k 2011-04-21 01:52:41 UTC
Created attachment 45908 [details]
Screenshot "error_ExtExample"
Comment 22 manj_k 2011-04-21 01:54:59 UTC
Created attachment 45909 [details]
Comparison 1: Screenshots "tools_macros_run_libo340b2.png"
Comment 23 manj_k 2011-04-21 01:57:31 UTC
Created attachment 45910 [details]
Comparison 2: Screenshot "tools_macros_run_libo332.png" (LibO 3.3.2)
Comment 24 vitriol 2011-04-21 01:59:42 UTC
I confirm. Broken again in 3.4 Beta 2...
Comment 25 Don't use this account, use tml@iki.fi 2011-04-21 02:06:18 UTC
Setting version to 3.4 beta1 as we don't have beta2 yet available there.
Comment 26 Don't use this account, use tml@iki.fi 2011-04-21 02:07:33 UTC
I am not sure it makes sense to reopen this old bug; the root cause might well be a very different one, even if the symptom is the same.
Comment 27 Rainer Bielefeld Retired 2011-04-21 03:10:44 UTC
<http://wiki.documentfoundation.org/BugReport_Details#Version>
Comment 28 manj_k 2011-04-21 04:02:20 UTC
Maybe relevent, or not...
It's also a bug in OOo DEV300m103.
(As far as I can see: still no bug report.)
Comment 29 manj_k 2011-04-21 04:34:15 UTC
...and therefore also broken in OOo 3.4 Beta [OOo-dev 3.4.0 OOO340m0 Build 9583].
Comment 30 Caolán McNamara 2011-05-01 03:44:01 UTC
caolanm->dtardon: can you check with petr if the vanilla packages are built with --with-ext-scripting-python or whatever its called or tweak it to be default yes.
Comment 31 David Tardon 2011-05-01 23:33:46 UTC
dtardon->caolanm: supposing comment 28 is right, it looks like the problem is somewhere else. but i'll ask anyway.
Comment 32 Alex Thurgood 2011-05-02 01:48:40 UTC
@ALL:

I just checked OOo-dev 340 (build 9583) on Mac OSX 10.6.7. The only python script that actually shows up in the Macros management dialog is the HelloWorld.py. There are entries (i.e. folder representations) for the other scripts, but they appear not to be present. This HelloWorld.py script also runs, so the python loader is functional here.


However, this looks like the same issue as one I posted previously for Mac, bug 34669 and which Christian and Caolan sorted out - certainly, the fix was entered for 3.3.2 final per the commits below.

http://cgit.freedesktop.org/libreoffice/libs-core/commit/?id=bef88b2ebf98faacedd911944ba20fe963498396

and 

http://cgit.freedesktop.org/libreoffice/libs-core/commit/?h=libreoffice-3-3&id=5c2ed6488e7619cb2fd2a1e996c46a81760822a9


With LibO 3.4 b4, if I look at the Tools-Macros-Organise Macros menu entry, I only have one entry, i.e. LibreOffice Basic, and the Basic macros are effectively the only ones that are displayed/visible. None of the others are available, i.e. no python, no JS, no Beanshell. However, if I inpsect the Mac app packet, I can see the scripts all present in /Contents/share/Scripts. So there is the possibility that we have the same problem as was resolved with thos previous commits for bug 34669. Perhaps they were overwritten by the OOo code merge ?

HTH

Alex
Comment 33 Alex Thurgood 2011-05-02 01:50:34 UTC
I meant LibO b3 and not b4 of course.

Alex
Comment 34 Alex Thurgood 2011-05-02 01:51:31 UTC
Perhaps we should close this and reopen 34669 instead ?


Alex
Comment 35 David Tardon 2011-05-03 07:49:42 UTC
it looks like it was caused by missing config option, in which case it should be okay in 3.4.0 beta4 (due tomorrow)
Comment 36 manj_k 2011-05-07 09:03:56 UTC
Sorry, no change (for me) with LibO 3.4.O Beta 4.
[The same issue as Comment 20]
Comment 37 manj_k 2011-05-11 14:50:54 UTC
LibO_3.4.0beta5_Win_x86_install_multi.exe [pre-release]
LibreOffice 3.4.0 
DEV300m103 (Build:5)

Tested again the examples in Comment 20: 

(1) ExtExample-1.0.1.oxt
could install/enable the extension.
The scripts work well.

(2) Tools > Macros > Run > LibreOffice Macros > HelloWorld
"HelloWorldPython" is available and works.
Tools > Macros > Organize Macros is complete again.

Also:
(3) Python script 'wc.py', added to my user profile, is now available and works.

Please confirm and set to FIXED VERIFIED again.
Comment 38 Petr Mladek 2011-05-16 09:07:16 UTC
Seems to be working in beta5 according to the comment #37 => mark as FIXED
Comment 39 Alex Thurgood 2011-05-16 09:47:48 UTC
Not working in beta 5 on Mac OSX. See bug 37015.


Alex
Comment 40 manj_k 2011-05-16 10:23:34 UTC
Maybe I should add:
That bug (33355) is about *Python* scripts.
Python (and Java) scripts work well with Beta 5 on WinXP 32b.

Beanshell scripts get an error message, but that's Bug 36915 (as I understand: fixed for RC 1).

[See also the attached screenshot]
Comment 41 manj_k 2011-05-16 10:25:24 UTC
Created attachment 46778 [details]
Screenshot: Hello World...
Comment 42 Caolán McNamara 2011-05-20 03:36:11 UTC
I think this is fixed, if not, open a new one, this bug is now officially a mess