Hello,
I am trying to run a Python script that is supposed to establish a connection to a MySQL database.
I already installed the package with pip install mysq.connector
.
When I run the script, I get an error:
BASIC runtime error. An exception occurred Type: com.sun.star.script.provider.ScriptFrameworkErrorException Message: <class 'ModuleNotFoundError'>: No module named 'mysql' File "/opt/libreoffice25.2/program/pythonscript.py", line 1063, in getScript mod = self.provCtx.getModuleByUrl( fileUri ) File "/opt/libreoffice25.2/program/pythonscript.py", line 492, in getModuleByUrl exec(code, entry.module.__dict__) File "/home/uli/.config/libreoffice/4/user/Scripts/python/YX.py", line 3, in <module> import mysql.connector File "/opt/libreoffice25.2/program/uno.py", line 346, in _uno_import return _builtin_import(name, *optargs, **kwargs)
I have no idea, what that means.
It means, the »python-environment« used by your manual installation of »/opt/libreoffice25.2« is different to the »python-environment« of you OS!
possible solutions:
- use apso.oxt from here to install »mysql«
- use LO provided by your friendly-Linux-distribution, which are linked to the »OS-python-environment«
Thank you very much for tips.
I set up a fresh Kubuntu installation. I also installed mysql.connector without using venv:
sudo apt install python3-mysql.connector
Now I get an other error:
BASIC-Laufzeitfehler.
Es ist eine Ausnahme aufgetreten
Type: com.sun.star.script.provider.ScriptFrameworkErrorException
Message: <class 'ModuleNotFoundError'>: No module named 'mysql'
File "/tmp/.mount_LibreOXharp1/opt/libreoffice24.8/program/pythonscript.py", line 1055, in getScript
mod = self.provCtx.getModuleByUrl( fileUri )
File "/tmp/.mount_LibreOXharp1/opt/libreoffice24.8/program/pythonscript.py", line 492, in getModuleByUrl
exec(code, entry.module.__dict__)
File "/home/uli/.config/libreoffice/4/user/Scripts/python/ETW.py", line 3, in <module>
import mysql.connector
File "/tmp/.mount_LibreOXharp1/opt/libreoffice24.8/program/uno.py", line 346, in _uno_import
return _builtin_import(name, *optargs, **kwargs)
It seems, LO can not find the system-wide installation of mysql.connector?
possible… especially, if I read
wich may imply your LibreOffice install is a Snap-container instead of a “regular” install via apt.