python and open office

Terry Reedy tjreedy at udel.edu
Wed Jul 27 15:01:24 EDT 2016


On 7/27/2016 12:37 PM, Chris Kaynor wrote:
> def __init__(self, name: str):
>
> That "name: str" syntax is called function annotations, and was added in
> Python 3, and you are trying to use the module in Python 2.7.
>
> There may be another variation of the module compatible with Python 2, or
> you'll need to upgrade your Python to a version of Python 3.
>
> Chris
>
> On Wed, Jul 27, 2016 at 9:28 AM, Crane Ugly <vostrushka at gmail.com> wrote:
>
>> I try to create some scripts that will help me to open and manipulate
>> OpenOffice documents. Calc in particular. But I have some problems finding
>> right packages or libraries that offer such interface.
>> So far I was trying uno and unotools but the first step is to import them
>> failed. Here is the output:
>>
>> UNO tools are installed:
>> $ pip list | grep uno
>> uno (0.3.3)
>> unotools (0.3.3)
>>
>> Try to import them:
>> $ python
>> Python 2.7.12 (default, Jun 29 2016, 12:53:15)
>> [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> import uno
>>>>> import unotools
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File
>> "/Volumes/home/lshanin/Dropbox/Python/ve/accounting/lib/python2.7/site-packages/unotools/__init__.py",
>> line 16
>>     def __init__(self, name: str):
>>                            ^
>> SyntaxError: invalid syntax
>>>>>
>>
>> I would appreciate is somebody help me to find what is wrong with untools
>> package.
>> Or point me to some other available libraries. I expect to work with
>> OpenOffice (LibreOffice) files only not with MS Excel files.

Are you working with OpenOffice or LibreOffice?  There are *different 
programs*.  Last I know, current LibreOffice comes with python 3.3.3 in 
its program directory and you need at least Python 3.3.3 for its UNO 
bridge, as it used the FSR unicode representation introduced in 3.3.

-- 
Terry Jan Reedy




More information about the Python-list mailing list