Page 1 of 1
Replacing stock Python
Posted: Tue Jan 26, 2010 6:54 pm
by zCRP
Hi I am trying to replace the stock supplied Python interpreter with the one I have installed myself.
My config:
OpenOffice 3.1.1 (which comes with Python 2.6.1) on WinXP V2002SP3
I am trying to use Python 2.6.2 so that I can more easily use external IDEs, install different modules etc.
I have tried following instructions from the following page
http://udk.openoffice.org/python/python ... #replacing, although they appear to refer to older versions of OO.
So I went and modified Basis\program\pythonloader.uno.ini like this:
Code: Select all
[Bootstrap]
PYUNO_LOADER_PYTHONHOME=c:/Programmi/python
PYUNO_LOADER_PYTHONPATH=c:/Programmi/python/Lib c:/Programmi/python/Lib/site-packages $ORIGIN
then I renamed the old python executables and dll in program, and finally went to cmd.exe, set the PATH and PYTHONPATH envvars, then launched python (2.6.2), but if I type "import uno" I get the error:
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named uno
Also, I have modified the standard HelloWorld.py macro that comes with OpenOffice so that it prints out sys.version from python. For some reason I still do not grasp, I am told that OO is still running python 2.6.1, even after all the renaming I did of the executables.
Anyone has any suggestions?
Thanks
Chris
Re: Replacing stock Python
Posted: Tue Jan 26, 2010 7:12 pm
by Villeroy
Re: Replacing stock Python
Posted: Wed Jan 27, 2010 11:03 am
by hanya
I tried in my environment:
Python 2.6.4: E:\usr\local\python26 (python26.dll is there)
OOo-dev DEV300m69: E:\usr\local\OOo\Dev69 (installed with /a option)
E:\usr\local\OOo\Dev69\OOo-dev 3\Basis\program\pythonloader.uno.ini
Code: Select all
[Bootstrap]
PYUNO_LOADER_PYTHONHOME=E:/usr/local/python26
PYUNO_LOADER_PYTHONPATH=E:/usr/local/python26/Lib E:/usr/local/python26/Lib/site-packages $ORIGIN
I removed these filed to load correct python.dll:
E:\usr\local\OOo\Dev63\OOo-dev 3\program\python26.dll
E:\usr\local\OOo\Dev63\OOo-dev 3\Basis\program\python26.dll
PATH:
Noe output of sys.version:
Code: Select all
2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
Re: Replacing stock Python
Posted: Wed Jan 27, 2010 12:46 pm
by Villeroy
May I ask what's wrong with the OOo's version of Python? Is there really any advantage writing office macros with the latest version?
I have written an extension in Python 2.3 that runs perfectly with all office versions since 1.1 (tested with 1.1.4 until 3.2).
Coding against the latest Python may produce incompatibilities against the vanilla version shipped with OpenOffice.org.
Re: Replacing stock Python
Posted: Wed Jan 27, 2010 12:48 pm
by zCRP
Thanks, in order to get "import uno" working from a python outside of openoffice, I also had to do the following:
Code: Select all
set PATH=C:\Program Files\OpenOffice.org 3\Basis\program;C:\Program Files\OpenOffice.org 3\URE\bin;C:\Program Files\OpenOffice.org 3\;%PATH%
set URE_BOOTSTRAP=file:///C:/Program%20Files/OpenOffice.org%203/program/fundamental.ini
set PYTHONPATH=C:\Programmi\python\Lib;C:\Programmi\python\Lib\site-packages;C:\Program Files\OpenOffice.org 3\Basis\program;
Tonight I will try the same steps on Mac Os X and post results.
Cheers
Chris
Re: Replacing stock Python
Posted: Mon Feb 01, 2010 10:49 pm
by zCRP
I am not really interested in the latest version of python. But what I would do like is being able to use a version of python which can be comfortably extended with whatever module I wish to throw at it. The stock python 2.6 that comes with snow leopard comes with goodies like easy_install, so adding extra modules is easy and fast. At the same time I can choose whatever ide I wish (ipython, idle etc.)
Re: Replacing stock Python
Posted: Fri May 16, 2014 4:23 pm
by Induane
Also, there are useful changes from python2.6.1 to 2.6.3 - for instance I have a number of tools that utilize httplib (not to mention the infamous requests library), but they all rely on a feature of httplib.py that doesn't exist until python 2.6.3 and as such my macros explode with errors like: VerifiedHTTPSConnection instance has no attribute '_tunnel_host' - which can be most troublesome. Using Python 2.6 isn't a big deal but it would be nice to at least updated it (not to mention 2.6.1 has some security issues that have been patched. A newer version of 2.6 will be api compatible and more secure. It's not always possible to get people away from a specific version of Office, and as such figuring out a clean way to do this would be nice

Re: Replacing stock Python
Posted: Fri May 16, 2014 5:18 pm
by karolus
Hallo
in meantime AOO4 is shipped with the latest Python from 2series (2.7.?)
Libreoffice4.x comes with Python3.3***
***except the LO-packages distributed by several Linux-distros - there is Python linked to SystemPython
Karolus
Re: Replacing stock Python
Posted: Fri May 16, 2014 9:01 pm
by Induane
Yep, and all that is nice, but if you have clients that require a specific version of OpenOffice, then the newer versions don't do you much good :/