关于 openerp:安装了 python2.6 和 python2.7 的 Python-uno 包问题

Python-uno package issue with python2.6 and python2.7 installed

我正在使用 OpenERP 和一个名为 report_openoffice 的模块。该模块需要安装包 python-uno。问题是我有 2 个版本的 python(2.6 和 2.7)。当我安装包时,Python2.7 可以使用包 python-uno 但 python2.6 不能。我需要在python2.6中使用它。有没有办法为 python 2.6 安装这个包?

PS:我在 Ubuntu 11.04

非常感谢


我将 uno.pyunohelper.py 从 2.7 软链接到 2.6,这似乎可行。
以 root 身份(或使用 sudo):

1
2
3
$> cd /usr/lib/python2.6/dist-packages
$> ln -s /usr/lib/python2.7/dist-packages/uno.py
$> ln -s /usr/lib/python2.7/dist-packages/unohelper.py

python-uno 常用于驱动 OpenOffice/LibreOffice。但是,如果您只想在 odt 或 pdf 文件中创建报告,则可以使用 PyQt4

显示如何写入 odt 文件的简单示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
>>>from pyqt4 import QtGui
# Create a document object
>>>doc = QtGui.QTextDocument()
# Create a cursor pointing to the beginning of the document
>>>cursor = QtGui.QTextCursor(doc)
# Insert some text
>>>cursor.insertText('Hello world')
# Create a writer to save the document
>>>writer = QtGui.QTextDocumentWriter()
>>>writer.supportedDocumentFormats()
[PyQt4.QtCore.QByteArray(b'HTML'), PyQt4.QtCore.QByteArray(b'ODF'), PyQt4.QtCore.QByteArray(b'plaintext')]
>>>odf_format = writer.supportedDocumentFormats()[1]
>>>writer.setFormat(odf_format)
>>>writer.setFileName('hello_world.odt')
>>>writer.write(doc) # Return True if successful
True

QTextCursor 还可以插入表格、框架、块、图像。更多信息。更多信息请访问:
http://qt-project.org/doc/qt-4.8/qtextcursor.html


uno 在 python 2.7 中安装包,然后运行以下命令:

1
2
3
4
sudo apt-get install libreoffice python-genshi python-cairo python-lxml python-setuptools
sudo apt-get install libreoffice-script-provider-python

easy_install uno