[Solved] Adding pythonw.exe to OOo3's python

Keyboard macros or custom scripts

[Solved] Adding pythonw.exe to OOo3's python

Postby dream2k9 » Mon Jan 04, 2010 8:57 pm

Hi,

I'm trying to understand how can I add "pythonw.exe" shipped with the official python 2.6 distribution to the OOO3's python. I have done some test, for example, copying pythonw.exe to the OOO3 python's, without any success.

Any ideas or useful pointer?

I'm running OOO3 on a winxp system. The official python release I'm using is the 2.6.1, the same of OOO3 one.

Thank you in advance and Happy New Year :),
Simone
Last edited by Hagar Delest on Fri Jan 08, 2010 12:19 am, edited 1 time in total.
Reason: tagged [Solved].
Openoffice 3.1 on Ubuntu Linux 9.10
OpenOffice 3.1 on windows xp
dream2k9
 
Posts: 5
Joined: Tue Dec 22, 2009 1:19 am

Re: Adding pythonw.exe to OOO3's python

Postby hanya » Tue Jan 05, 2010 7:33 pm

The shipped python.exe (placed in the program directory, not in the python-core-version\bin) with the OOo sets a few environment variables to work correctly.
"PATH" for to find libpyuno.so file and load it to work. "URE_BOOTSTRAP" is used to load UNO components. "UNO_PATH" is used to start OOo, this variable is optional, I think.
You can know these variables on your python like the following code:
Code: Select all   Expand viewCollapse view
import os
print(os.environ['PATH'])
print(os.environ['URE_BOOTSTRAP'])
print(os.environ['UNO_PATH'])

I can connect to OOo through another python installation with these variables.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 881
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Adding pythonw.exe to OOO3's python

Postby dream2k9 » Thu Jan 07, 2010 12:32 am

Hi Hanya,

thank you for reply!

hanya wrote:The shipped python.exe (placed in the program directory, not in the python-core-version\bin) with the OOo sets a few environment variables to work correctly.
"PATH" for to find libpyuno.so file and load it to work. "URE_BOOTSTRAP" is used to load UNO components. "UNO_PATH" is used to start OOo, this variable is optional, I think.
You can know these variables on your python like the following code:
Code: Select all   Expand viewCollapse view
import os
print(os.environ['PATH'])
print(os.environ['URE_BOOTSTRAP'])
print(os.environ['UNO_PATH'])

I can connect to OOo through another python installation with these variables.


Tomorrow I will try to:

1. install oo3 on a clean XP machine
2. Install the official python 2.6.4 [1]
3. add vars you indicated to my environment( system properties-variables).
4. start c:\python26\python.exe and c:\python26\pythonw.exe to try "import uno".

Simone

[1] I verified that if you install the official python, when you launch ``c:\programmi\oo3...\program\python.exe``, the python interpreter shows that is using the "python 2.6.4 core" and more the 2.6.1 shipped with ooo3. What version of core shows to you the ooo3's python?
Openoffice 3.1 on Ubuntu Linux 9.10
OpenOffice 3.1 on windows xp
dream2k9
 
Posts: 5
Joined: Tue Dec 22, 2009 1:19 am

Re: Adding pythonw.exe to OOO3's python

Postby dream2k9 » Thu Jan 07, 2010 4:13 pm

hanya wrote:The shipped python.exe (placed in the program directory, not in the python-core-version\bin) with the OOo sets a few environment variables to work correctly.
"PATH" for to find libpyuno.so file and load it to work. "URE_BOOTSTRAP" is used to load UNO components. "UNO_PATH" is used to start OOo, this variable is optional, I think.


I found that under windows the libpyuno.so is renamed in c:\programmi\OpenOffice.org 3\Basis\program\pyuno.pyd

hanya wrote:You can know these variables on your python like the following code:
Code: Select all   Expand viewCollapse view
import os
print(os.environ['PATH'])
print(os.environ['URE_BOOTSTRAP'])
print(os.environ['UNO_PATH'])

I can connect to OOo through another python installation with these variables.


Here is what I did (thanks very much hanya for help!)

1. installed ooo3
2. installed the official python 2.6.4 to c:\python26
3. configured the windows environment ADDING the variables URE_BOOTSTRAP and UNO_PATH and modifying the PATH variable as follows :

Code: Select all   Expand viewCollapse view
URE_BOOTSTRAP    vnd.sun.star.pathname:C:\Programmi\OpenOffice.org 3\program\fundamental.ini
UNO_PATH    C:\Programmi\OpenOffice.org 3\program\
PATH    C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\python26;C:\Programmi\OpenOffice.org 3\URE\bin;C:\Programmi\OpenOffice.org 3\Basis\program;c:\GTK2\bin;c:\GTK2\lib;


4. Added a .pth file in c:\python26\Lib\site-packages\uno.pth with the following content :
Code: Select all   Expand viewCollapse view
c:\\programmi\\OpenOffice.org 3\\Basis\program


Now I can launch my gtk apps with pythonw.exe and import the uno module :)

Simone
dream2k9
 
Posts: 5
Joined: Tue Dec 22, 2009 1:19 am

Re: [Solved] Adding pythonw.exe to OOo3's python

Postby zCRP » Tue Jan 26, 2010 11:46 pm

Hi, has anyone been able to replicate this feat under Mac Os X (Snow Leopard 10.6.2)?

I did as follows:
1) edited environment variables
Code: Select all   Expand viewCollapse view
UNO_PATH=/Applications/OpenOffice.org.app/Contents/program/
URE_BOOTSTRAP=vnd.sun.star.pathname:/Applications/OpenOffice.org.app/Contents/program/fundamentalrc
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Applications/OpenOffice.org.app/Contents/program:/Applications/OpenOffice.org.app/Contents/basis-link/ure-link/bin

2) addes uno.pth to /Library/Python/2.6/site-packages/uno.pth with content
Code: Select all   Expand viewCollapse view
/Applications/OpenOffice.org.app/Contents/program

at this point I run system default python (snow leopard comes preinstalled with 2.6.1, and when I try "import uno" I get the dreaded
Code: Select all   Expand viewCollapse view
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named uno
OpenOffice 3.1.1 on MacOS 10.6.2
zCRP
 
Posts: 10
Joined: Tue Jan 26, 2010 12:15 am

Re: [Solved] Adding pythonw.exe to OOo3's python

Postby hanya » Wed Jan 27, 2010 9:54 am

I don't have MacOSX environment but "LD_LIBRARY_PATH" is used on UNIX like environment to find libpyuno.so that is differ with the Windows PATH.

2. Have you tried to add the path to the uno.py manyally?
Code: Select all   Expand viewCollapse view
import sys
sys.path.append(path to the directory of the uno.py)
import uno
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 881
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest