OpenOffice.org development with pyUno for Windows—which Python?

浪子不回头ぞ 提交于 2019-12-19 02:46:10

问题


At home, on Linux, I've experimented with pyUNO to control OpenOffice.org using Python. I've been using Python 2.6. It all seems to work nicely.

Now I thought I would try one of my scripts (run a graphical diff for ODF doc) on Windows. But when I tried to run it, I got:

ImportError: No module named uno

According to udk: Python UNO Bridge and OpenOffice.org Running Python on Windows, I have to run the Python interpretter that's installed with OpenOffice.org.

Q1: Is Python 2.6 available for OpenOffice.org?

However, that interpreter is Python 2.3, which is getting a little old! and my script uses a feature not supported by 2.3 (subprocess module).

Q2: Can pyUNO programming on Windows be done with a pyUNO add-on to the standard Python distribution, not the Python that is bundled with OpenOffice.org?

In my searching so far, I haven't been able to find any indication that there is a pyUNO module available to be installed into the standard Python Windows distribution... which is a surprise because on Ubuntu Linux, UNO is supported just fine in Python just by:

 apt-get install python-uno

Another problem with this is: what if I want to make a program that uses both pyUNO and other 3rd party libraries? I can't install pyUNO into my Python installation on Windows, so am I forced to somehow install my other 3rd party libraries into OpenOffice.org's bundled Python? It makes it difficult to create larger, more full-featured programs.

Am I missing something, or are we stuck with this situation for now?


回答1:


You can import uno into your system's python on Win32 systems. (Not Python 3 yet). Tutorial at http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=36370&p=166783 It's not difficult - import three environment variables, and append one item to your pythonpath.

For additional flexibility, you can use the COM-UNO bridge instead of the Python-UNO bridge. The syntax is generally quite similar, and you can use any version of Python (including Python3). Info at http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=36608&p=167909




回答2:


Per openoffice's docs, the Python version supported is WAY behind -- "Efforts on moving PyUNO to Python 2.5 continue", 2.6 not even on the map. So "stuck with this situation for now" is a fair assessment!-)




回答3:


OpenOffice.org 3.1 comes with Python 2.6.1. (As I recall, it was a fairly last-minute merge that ticked some people off, but it's there and it works.) Now the docs are the only thing hopelessly out-of-date. :)



来源:https://stackoverflow.com/questions/994429/openoffice-org-development-with-pyuno-for-windows-which-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!