How to import uno with Python/macOS?

Java, C++, C#, Delphi, ??? - Using the UNO bridges

How to import uno with Python/macOS?

Postby pasza » Thu Jan 11, 2018 1:14 am

Any idea how to "import uno" within a Python script being managed by a system Python distribution?

> /usr/local/bin/python3
Python 3.6.4 (default, Jan 6 2018, 11:51:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
>>> import uno
ModuleNotFoundError: No module named 'uno'
OpenOffice 4.1.5 on macOS 10.12.6
pasza
 
Posts: 2
Joined: Thu Jan 11, 2018 1:06 am

Re: How to import uno with Python/macOS?

Postby Villeroy » Thu Jan 11, 2018 1:37 am

Use the Python interpreter that is shipped with the Office suite. It is Python3 with LibreOffice and Python2 with OpenOffice.
http://christopher5106.github.io/office ... acros.html
https://conference.libreoffice.org/asse ... sPyUNO.pdf
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 25272
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to import uno with Python/macOS?

Postby pasza » Thu Jan 11, 2018 2:25 am

Thanks. But there is no python at my AOO installation - how to get it?

> ll -1 /Applications/OpenOffice.app/Contents/MacOS/*python*
/Applications/OpenOffice.app/Contents/MacOS/pythonloader.py
/Applications/OpenOffice.app/Contents/MacOS/pythonloader.uno.dylib
/Applications/OpenOffice.app/Contents/MacOS/pythonloader.unorc
/Applications/OpenOffice.app/Contents/MacOS/pythonscript.py


P.S. I'd still like to use a python interpreter chosen by me.
OpenOffice 4.1.5 on macOS 10.12.6
pasza
 
Posts: 2
Joined: Thu Jan 11, 2018 1:06 am

Re: How to import uno with Python/macOS?

Postby Lupp » Thu Jan 11, 2018 12:48 pm

What about
Code: Select all   Expand viewCollapse view
(PieceOfPathToThe_soffice.exe)\program\python-core-2.7.6
On Windows 10: LibreOffice 5.4.4 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Maybe we might! (Create a powerful UFO: United Free Office)
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 1793
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How to import uno with Python/macOS?

Postby RoryOF » Thu Jan 11, 2018 2:46 pm

On my Xubuntu system, uno.py is at /opt/openoffice4/program; Normally, when a python script is opened as a macro in OpenOffice this is found automatically. If you wish to use it in the python interpreter (say for debugging), you should add that to your PYTHONPATH.

To find python on your computer, try "whereis python" and "which python" in a terminal (no quotes)
Apache OpenOffice 4.1.5 on Xubuntu 18.04 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 26536
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: How to import uno with Python/macOS?

Postby MrProgrammer » Thu Jan 11, 2018 5:13 pm

Hi, and welcome to the forum.

pasza wrote:But there is no python at my AOO installation - how to get it?
With no Python configuration on Mac OSX 9.5 and OpenOffice 3.2 I have
~ $ find /Applications/OpenOffice.org.app/ -name uno.py
/Applications/OpenOffice.org.app//Contents/basis-link/program/uno.py
~ $ whereis python
/usr/bin/python
~ $ python -V
Python 2.7.5

As a test, try Tools → Macros → Run macro → OpenOffice macros → pythonSamples → TableSample → createTable → Run

~ $ find /Applications/OpenOffice.org.app/ -name TableSample.py
/Applications/OpenOffice.org.app//Contents/basis-link/share/Scripts/python/pythonSamples/TableSample.py

pasza wrote:I'd still like to use a python interpreter chosen by me.
That would seem to me to be a Python installation issue, not an OpenOffice issue.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
OpenOffice 3.2.0 Build 9483 on Mac OS X 10.9.5.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
MrProgrammer
Volunteer
 
Posts: 3293
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: How to import uno with Python/macOS?

Postby Villeroy » Thu Jan 11, 2018 6:41 pm

http://christopher5106.github.io/office ... acros.html explains LO-Python on the Mac and mentions the executable /Applications/LibreOffice.app/Contents/MacOS/python
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 25272
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest