Python 2.7 with pyuno

三世轮回 提交于 2019-12-01 04:05:07

问题


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.


回答1:


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




回答2:


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
    



回答3:


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


来源:https://stackoverflow.com/questions/7763972/python-2-7-with-pyuno

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!