Description: MAC OS X build in Python can't import uno Version: 6.4.0.1 Build ID: 1b6477b31f0334bd8620a96f0aeeb449b587be9f CPU threads: 16; OS: Mac OS X 10.15.2; UI render: default; VCL: osx; Locale: en-US (en_TW.UTF-8); UI-Language: en-US Calc: threaded Steps to Reproduce: 1. download dmg and install 2. using build in python 3. >>> import uno Actual Results: import error Expected Results: import success Reproducible: Always User Profile Reset: Yes Additional Info: [Information automatically included from LibreOffice] Locale: en-US Module: TextDocument [Information guessed from browser] OS: Mac OS X (All) OS is 64bit: no
@gshmu : a few more details would be handy. From where are you using "import uno" ? Do any of the pre-provided python scripts work from within LO? If so, then you are probably not using "import uno" as it is intended to be used
For example, take the script TableSample.py provided in the Scripts directory : /Applications/LibreOffice.app/Contents/Resources/Scripts/python/pythonSamples/TableSample.py This script runs just fine for me when LO is already launched. The first uncommented line in that script is "import uno". If you want to use LO python from a script stored outside of Scripts folder of the app bundle, then things are going to get complicated as you will need to differentiate between the local python installation on your Mac, and the python environment within LO.
For example, default python on macOS Catalina is still 2.7. Even Apple advises changing this to the included 3.7.3 (xcrun python3). However, please note that the default version of python included with LO63 is 3.5. If you run : /Applications/LibreOffice.app/Contents/Resources/python -vvv you will see the list of pre-installed modules that can be called on, provided that you bootstrap the correct python context.
(In reply to Alex Thurgood from comment #1) > @gshmu : a few more details would be handy. > > From where are you using "import uno" ? > > Do any of the pre-provided python scripts work from within LO? > > If so, then you are probably not using "import uno" as it is intended to be > used ``` /Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/Versions/3.5/bin/python3 Python 3.5.9 (default, Dec 18 2019, 14:49:58) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import python Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'python' >>> ``` I'm run the '/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/Versions/3.5/bin/python3'
From a terminal, if I enter : /Applications/LibreOffice.app/Contents/Resources/python the interactive shell then allows me to import uno import os i.e. I can import the modules that are pre-included in the LO-supplied version of python. In order to find out which modules have been included in this version: help(modules) or just type : help then in the interactive help type : modules A list of the available modules you can access is displayed, for example : help> modules Please wait a moment while I gather a list of all available modules... __future__ antigravity imaplib select _ast argparse imghdr selectors _bisect array imp setuptools _bootlocale ast importlib shelve _bz2 asynchat inspect shlex _codecs asyncio io shutil _codecs_cn asyncore ipaddress signal _codecs_hk atexit itertools site _codecs_iso2022 audioop json smtpd _codecs_jp base64 keyword smtplib _codecs_kr bdb lib2to3 sndhdr _codecs_tw binascii linecache socket _collections binhex locale socketserver _collections_abc bisect logging sqlite3 _compat_pickle builtins lzma sre_compile _compression bz2 macpath sre_constants _crypt cProfile macurl2path sre_parse _csv calendar mailbox ssl _ctypes cgi mailcap stat _ctypes_test cgitb mailmerge statistics _curses chunk marshal string _curses_panel cmath math stringprep _datetime cmd mimetypes struct _dbm code mmap subprocess _decimal codecs modulefinder sunau _dummy_thread codeop msgbox symbol _elementtree collections multiprocessing symtable _functools colorsys netrc sys _hashlib compileall nis sysconfig _heapq concurrent nntplib syslog _imp configparser ntpath tabnanny _io contextlib nturl2path tarfile _json copy numbers telnetlib _locale copyreg officehelper tempfile _lsprof crypt opcode termios _markupbase csv operator textwrap _md5 ctypes optparse this _multibytecodec curses os threading _multiprocessing datetime parser time _opcode dbm pathlib timeit _operator decimal pdb tkinter _osx_support difflib pickle token _pickle dis pickletools tokenize _posixsubprocess distutils pip trace _pydecimal doctest pipes traceback _pyio dummy_threading pkg_resources tracemalloc _random easy_install pkgutil tty _scproxy email platform turtle _sha1 encodings plistlib turtledemo _sha256 ensurepip poplib types _sha512 enum posix typing _signal errno posixpath unicodedata _sitebuiltins faulthandler pprint unittest _socket fcntl profile uno _sqlite3 filecmp pstats unohelper _sre fileinput pty urllib _ssl fnmatch pwd uu _stat formatter py_compile uuid _string fractions pyclbr venv _strptime ftplib pydoc warnings _struct functools pydoc_data wave _symtable gc pyexpat weakref _sysconfigdata genericpath pythonloader webbrowser _testbuffer getopt pythonscript wizards _testcapi getpass pyuno wsgiref _testimportmultiple gettext queue xdrlib _testmultiphase glob quopri xml _thread grp random xmlrpc _threading_local gzip re xxlimited _tracemalloc hashlib readline xxsubtype _warnings heapq reprlib zipapp _weakref hmac resource zipfile _weakrefset html rlcompleter zipimport abc http runpy zlib aifc idlelib sched
(In reply to Alex Thurgood from comment #5) > From a terminal, if I enter : > > /Applications/LibreOffice.app/Contents/Resources/python > thank you. where to get more info about LibreOfficePython & LibreOfficePython.framework etc. i see the LibreOfficePython has run permision, but could not be run. ``` $ ll /Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/LibreOfficePython lrwxr-xr-x 1 gshmu admin 34 Dec 19 01:24 /Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/LibreOfficePython@ -> Versions/Current/LibreOfficePython $ /Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/LibreOfficePython zsh: exec format error: /Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/LibreOfficePython ```