我在 Windows 7 上安装了 python 2.7。我已经安装了 python 2.6 附带的 Libre Office 3.4。因此,即使设置了所有环境变量,我也无法导入 uno 和 unohelper。
我需要 python 2.7,因此无法恢复到 python 2.6,因为我之前使用 python 2.6 与 open office 3 一起工作。我最近更改为 LibreOffice 3.4 和 Python 2.7(ActivePython 2.7)。
有什么方法可以让 python 2.7 导入 LibreOffice 3.4 的 uno 和 unohelper
提前致谢。
最佳答案
.pyc
文件和 C 扩展在 2.6 和 2.7 Python 版本之间不兼容。安装pylauncher并在与 Libre Office 配合使用的脚本中使用 python2.6 shebang。
来自 OpenOffice.org development with pyUno for Windows—which Python? 的答案中提供的链接问题:
Terms: Let's call the version of Python installed with OpenOffice the 'OO-Python'. Let's call the version of Python installed separately (to c:\Python26, for example) the 'System-Python'.
You need to know SIX things to sucessfully import the uno module into your System-Python interpreter. 1) The OO-Python version number. Your System-Python version number must be the same as your OO-Python version number. [emphasis mine] ...
关于带有 pyuno 的 Python 2.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7763972/