Python 2.7 with pyuno
Asked Answered
M

3

5

I am having python 2.7 installed on my windows 7. I have installed Libre Office 3.4 which comes with python 2.6. Hence i am not able to import uno and unohelper even after setting all environment variables.

I need python 2.7 thus cannot revert back to python 2.6, as i earlier had python 2.6 working with open office 3. I recently changed to LibreOffice 3.4 and Python 2.7(ActivePython 2.7).

Is there any way i can make python 2.7 to import uno and unohelper of LibreOffice 3.4

Thanks in advance.

Mchugh answered 14/10, 2011 at 6:43 Comment(0)
S
3

.pyc files and C extensions are not compatible between 2.6 and 2.7 Python versions. Install pylauncher and use python2.6 shebang in scripts that work with Libre Office.

From the link provided in the answer to OpenOffice.org development with pyUno for Windows—which Python? question:

Terms: Let's call the version of Python installed with OpenOffice the 'OO-Python'. Let's call the version of Python installed separately (to c:\Python26, for example) the 'System-Python'.

You need to know SIX things to sucessfully import the uno module into your System-Python interpreter. 1) The OO-Python version number. Your System-Python version number must be the same as your OO-Python version number. [emphasis mine] ...

Switzer answered 14/10, 2011 at 7:5 Comment(2)
I do not have Python2.6 installed on my system so i tried giving the path of python.exe present in the LibreOffice 3.4 as "C:\Program Files (x86)\LibreOffice 3.4\program\python.exe". I am unaware as to what i am trying is correct or not and whether this way of providing python executable version required for my script is correct or not.Mchugh
@PyBegginer: If the versions of System and LibreOffice python are different then you can't run the code that uses pyuno installed with LibreOffice with your System python. It doesn't prevent you from running it using the python from the path you posted. pylauncher allows you to run your scripts without specifying python version every time (you do it once inside your script in the '#!'-line). View the screencast.Switzer
G
3

ubuntu 13.10 and later , you need to install openoffice 4.1.1.

  1. uninstall libreoffice and openoffice

    sudo apt-get remove libreoffice* openoffice*
    sudo apt-get autoremove
    
  2. install Apache OpenOffice 4.1.1 on 64 bit Ubuntu

    wget sourceforge.net/projects/openofficeorg.mirror/files/4.1.1/binaries/en-GB/Apache_OpenOffice_4.1.1_Linux_x86-64_install-deb_en-GB.tar.gz
    tar -xzvf Apache_OpenOffice_4.1.1_Linux_x86-64_install-deb_en-GB.tar.gz
    cd en-GB/DEBS
    sudo dpkg -i *.deb
    cd desktop-integration
    sudo dpkg -i *.deb
    
  3. install Apache OpenOffice 4.1.1 on 32 bit Ubuntu

    wget sourceforge.net/projects/openofficeorg.mirror/files/4.1.1/binaries/en-GB/Apache_OpenOffice_4.1.1_Linux_x86_install-deb_en-GB.tar.gz
    tar -xzvf Apache_OpenOffice_4.1.1_Linux_x86_install-deb_en-GB.tar.gz
    cd en-GB/DEBS
    sudo dpkg -i *.deb
    cd desktop-integration
    sudo dpkg -i *.deb
    
  4. touch uno.pth for python2.7

    echo /opt/openoffice4/program |sudo tee /usr/lib/python2.7/dist-packages/uno.pth
    
Gloriagloriana answered 16/1, 2015 at 8:56 Comment(0)
U
1

In ubuntu 14.04

open the terminal and run the following command...

sudo apt-get install libreoffice python-genshi python-cairo python-lxml python-setuptools
sudo apt-get install libreoffice-script-provider-python
easy_install uno
Unicycle answered 14/10, 2016 at 11:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.