使用 pyUno for Windows 进行 OpenOffice.org 开发——哪种 Python?

发布于 2024-07-23 11:24:18 字数 1264 浏览 9 评论 0原文

在家里的 Linux 上,我尝试使用 pyUNO 来使用 Python 控制 OpenOffice.org。 我一直在使用Python 2.6。 一切似乎都很顺利。

现在我想我应该尝试我的一个脚本(为 ODF 文档运行图形差异)在 Windows 上。 但是当我尝试运行它时,我得到:

ImportError: No module named uno

根据 udk: Python UNO BridgeOpenOffice.org 在 Windows 上运行 Python,我必须运行已安装的 Python 解释器与 OpenOffice.org。

问题1:OpenOffice.org 可以使用Python 2.6 吗?

但是,该解释器是Python 2.3,它有点老了! 我的脚本使用了 2.3 不支持的功能(subprocess 模块)。

问题 2:Windows 上的 pyUNO 编程是否可以通过标准 Python 发行版的 pyUNO 插件(而不是与 OpenOffice.org 捆绑在一起的 Python)来完成?

在我迄今为止的搜索中,我还没有能够找到任何迹象表明有一个 pyUNO 模块可以安装到标准 Python Windows 发行版中...这是一个惊喜,因为在 Ubuntu Linux 上,UNO 在 Python 中得到了很好的支持:

 apt-get install python-uno

另一个问题是:什么如果我想制作一个同时使用 pyUNO 和其他第 3 方库的程序? 我无法将 pyUNO 安装到 Windows 上的 Python 安装中,因此我是否被迫以某种方式将其他第 3 方库安装到 OpenOffice.org 的捆绑 Python 中? 它使得创建更大、功能更全的程序变得困难。

我是否遗漏了什么,或者我们现在陷入了这种情况?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甚是思念 2024-07-30 11:24:18

根据 openoffice 的文档,支持的 Python 版本远远落后于 --“移动 PyUNO 的努力到Python 2.5继续”,2.6甚至不在地图上。 因此,“目前处于这种情况”是一个公平的评估!-)

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!-)

耀眼的星火 2024-07-30 11:24:18

OpenOffice.org 3.1 附带 Python 2.6.1。 (我记得,这是最后一刻的合并,让一些人恼火,但它确实存在并且有效。) 现在文档是唯一无可救药地过时的东西。 :)

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. :)

醉生梦死 2024-07-30 11:24:18

您可以将 uno 导入到 Win32 系统上的 python 中。 (还不是 Python 3)。 教程位于 http://user .services.openoffice.org/en/forum/viewtopic.php?f=45&t=36370&p=166783
这并不困难 - 导入三个环境变量,并将一项附加到您的 pythonpath 中。

为了获得额外的灵活性,您可以使用 COM-UNO 桥而不是 Python-UNO 桥。 语法通常非常相似,您可以使用任何版本的 Python(包括 Python3)。 信息位于 http://user .services.openoffice.org/en/forum/viewtopic.php?f=45&t=36608&p=167909

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文