在 Ubuntu 上的 python 中导入 OOSheet 时出错

Posted

技术标签:

【中文标题】在 Ubuntu 上的 python 中导入 OOSheet 时出错【英文标题】:Error when importing OOSheet in python on Ubuntu 【发布时间】: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

【问题讨论】:

【参考方案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。感谢您指出这一点!

以上是关于在 Ubuntu 上的 python 中导入 OOSheet 时出错的主要内容,如果未能解决你的问题,请参考以下文章

在 macOS 10.14.6 上的 Python 3.7.4 中导入 ssl 时出错

在 Mac 上的 Python 2.7.3 中导入 .pyd(使用 SWIG 创建)

Caffe没有在python中导入

为啥我无法在 Google Colab 中导入 python-rosbag?

如何在mac上的python中导入非标准包?此软件包不支持pip安装

Ubuntu 上的 Tensorflow 和 Anaconda?