7

How do you make Python (any Python) know about PyUno in LibreOffice?

When I do:

import uno

python says that it knows no module "uno". (This question came up re. this question.)

Community
  • 1
  • 1
Prof. Falken
  • 24,226
  • 19
  • 100
  • 173

6 Answers6

5

(UPDATING for 2014's)

Perhaps the most used UNO application is document conversion... For this task, in nowadays, you not need UNO, you can use directly

libreoffice --convert-to

About UNO itself, see the new home page, http://api.libreoffice.org/

A good example of using python3-uno (or python-uno) is the Docvert conversor (Docvert for py2).

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
  • 1
    This answer saved me a huge amount of time debugging endless issues with unoconv. – udog Oct 31 '19 at 14:39
3

For Debian, Ubuntu, and derivates:

sudo apt install libreoffice-script-provider-python
Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
Mhadhbi issam
  • 197
  • 3
  • 6
2

I am having the same issue with ubuntu 14.04 and python 2.7.6.

But if you are using ubuntu 12.04, try using sudo apt-get install python-uno.

Community
  • 1
  • 1
user1839132
  • 121
  • 2
  • 10
2

As said in the response to your comment there: it's an optional installable component for OpenOffice. See the Introduction to Python on OOo page in OpenOffice's Wiki for installation details

jro
  • 9,300
  • 2
  • 32
  • 37
1

Here's what I did:

inside the LibreOffice directory, there is a "program" directory with a python.exe, if I use that python (which is at version 2.6.1), I can import uno.

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
  • This is not a solution to your question. It's just a workaround. – David Dec 28 '11 at 22:49
  • 2
    It seems to me that using the built-in Python (as of LibreOffice4 and Python 3.3) is the only option here. I have a very hard time finding out how I can install pyuno for my working Python environment... – Jens Mar 05 '13 at 11:51
  • 2
    @Clark, with some tweaking and working around the lack of other packages it worked for me too, it's just a bit of an annoyance to be constrained by that. Having said that, I did not try to re-install the packages for LO-Python. Would be nice if pyuno was provided as a PIP package... – Jens Mar 05 '13 at 19:49
-1

Try importing the libre office python extension.

yum install libreoffice-pyuno