2011-09-23 62 views
1

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

PS:我在Ubuntu 11.04

非常感谢您

回答

2

我软链接从2.7 uno.pyunohelper.py到2.6,并且似乎工作。 作为根做(或者与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

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

-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