Linux的
dirkjot's answer此主题在Linux上的伟大工程。
的Mac(约塞米蒂)
事情变得有点棘手这里,而随着LibreOffice的4.3我还是不能没有崩溃在Mac致以PYTHONPATH
到的LibreOffice和import uno
:
localhost ~ > PYTHONPATH=$PYTHONPATH:/Applications/LibreOffice64.app/Contents/MacOS python3.3
Python 3.3.6 (default, Nov 12 2014, 18:18:46)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import uno
Segmentation fault: 11
但这是对我有用的东西。 首先,我必须确保Python和我的LibreOffice都是为32b或64b构建的;他们不能混合。我正在使用Python 3.3附带的64b MacPorts Python 3.3和64b LibreOffice for Mac(download link)。 二,我必须确保运行正确的Python并正确地扩展PYTHONPATH
。因为我不能运行我的MacPorts Python和用的LibreOffice的路径扩展它,我会一个人做的另一种方式:运行LibreOffice的Python和我的MacPorts Python的路径扩展它:
localhost ~ > PYTHONPATH=$PYTHONPATH:/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages /Applications/LibreOffice64.app/Contents/MacOS/python
Python 3.3.5 (default, Dec 12 2014, 10:33:58)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import uno
>>> import lxml
>>>
注意如何uno
是从LibreOffice的Python路径导入,lxml
居住在MacPort的Python路径中。
我在Ubuntu 13.04中有LibreOffice 4,但在任何Tools-Macro子菜单中都没有提到Python。你有吗? – stenci 2013-07-29 03:29:48
不确定Ubuntu,但在我的Mac上,python解释器是/Applications/LibreOffice.app/Contents/MacOS中的一部分。 UNO包装生活在同一个文件夹中。这一切都是作为LibreOffice软件包的一部分。 – Jens 2013-07-29 09:48:39
相关:http://stackoverflow.com/questions/24965406/getting-python-to-import-uno-pyuno – Jens 2014-10-09 11:26:28