【问题标题】:Error when importing OOSheet in python on Ubuntu在 Ubuntu 上的 python 中导入 OOSheet 时出错
【发布时间】:2016-02-04 16:23:03
【问题描述】:

我正在尝试使用库 oosheet 通过 python 脚本编辑 Libreoffice-calc 工作表。我已按照他们的文档进行操作,并且似乎已正确安装。但是当我在 python shell 中运行“from oosheet import OOSheet as S”时,我返回了这个:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/herm/.local/lib/python2.7/site-packages/oosheet/__init__.py", line 30, in <module>
from com.sun.star.awt import WindowDescriptor
ImportError: No module named com.sun.star.awt

【问题讨论】:

    标签: python ubuntu libreoffice


    【解决方案1】:

    在我的 Ubuntu 系统(14.04 Trusty,LO 4.2.8.2)上,LibreOffice 使用 python 3。所以这适用于终端:

    python3
    >>> import uno
    >>> from com.sun.star.awt import WindowDescriptor
    

    但这失败了:

    python
    >>> import uno
    ImportError: No module named uno
    

    OOSheet 网站并没有说它适用于 python 3,因此您可能需要切换到 AOO,它仍然使用 python 2。或者为什么不直接使用 PyUNO 而不是 OOSheet。

    【讨论】:

    • 啊,我只是在运行 python,而不是 python3。感谢您指出这一点!
    猜你喜欢
    • 2017-06-22
    • 2012-12-24
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 1970-01-01
    • 2018-04-29
    • 2018-04-26
    相关资源
    最近更新 更多