问题描述
在家里,在Linux上,我已经尝试使用pyUNO使用Python控制OpenOffice.org.我一直在使用Python 2.6.一切似乎都很好.
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.
现在,我想我可以尝试使用我的一个脚本(为ODF文档运行图形化差异)(在Windows上).但是当我尝试运行它时,我得到了:
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
根据 udk:Python UNO Bridge 和 OpenOffice.org在Windows上运行Python ,我必须运行与OpenOffice.org一起安装的Python解释器.
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.
问题1:Python 2.6是否可用于OpenOffice.org?
但是,该解释器是 Python 2.3 ,它已经有点老了!而我的脚本使用的是2.3(subprocess
模块)不支持的功能.
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).
第二季度:Windows上的pyUNO编程是否可以通过标准Python发行版中的pyUNO插件来完成,而不是与OpenOffice.org捆绑在一起的Python来完成?
到目前为止,在搜索中,我还没有发现任何迹象表明可以将pyUNO模块安装到标准Python Windows发行版中.这令人惊讶,因为在Ubuntu Linux上支持UNO.只需在Python中执行以下操作即可:
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
另一个问题是:如果我想制作一个同时使用pyUNO和其他第三方库的程序,该怎么办?我无法将pyUNO安装到Windows上的Python安装中,所以我是否被迫以其他方式将其他第3方库安装到OpenOffice.org捆绑的Python中?这样就很难创建更大,功能更全的程序.
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?
推荐答案
您可以将uno导入Win32系统上的系统python中. (还不是Python 3).教程位于 http://user .services.openoffice.org/en/forum/viewtopic.php?f = 45& t = 36370& p = 166783 这并不困难-导入三个环境变量,然后将一项添加到pythonpath中.
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=166783It's not difficult - import three environment variables, and append one item to your pythonpath.
为获得更大的灵活性,可以使用COM-UNO桥而不是Python-UNO桥.语法通常非常相似,您可以使用任何版本的Python(包括Python3).信息位于 http://user .services.openoffice.org/en/forum/viewtopic.php?f = 45& t = 36608& p = 167909
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
这篇关于使用pyUno for Windows的OpenOffice.org开发-哪个Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!