安装了python2.6和python2.7的Python-uno包问题

时间:2011-09-23 09:17:11

标签: python openerp uno

我正在使用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

非常感谢

3 个答案:

答案 0 :(得分:2)

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

$> 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

答案 1 :(得分:1)

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

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

>>>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

答案 2 :(得分:-1)

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

sudo apt-get install libreoffice python-genshi python-cairo python-lxml python-setuptools
sudo apt-get install libreoffice-script-provider-python

easy_install uno