chaquo / chaquopy

Chaquopy: the Python SDK for Android
https://chaquo.com/chaquopy/
MIT License
748 stars 127 forks source link

'import pyhrv' gets 'no module tkinter error' #1145

Closed ChaeYeon01 closed 1 month ago

ChaeYeon01 commented 2 months ago

Chaquopy version

15.0

Devices or emulators where the issue happens

Relevant parts of your code

python script import cv2 import numpy as np import time import pyhrv

build.gradle chaquopy{ defaultConfig { version = "3.8" pip{ install("opencv-python") install("numpy") install("spectrum") install("scipy") install("pyhrv") } }

Describe your issue

I need to import pyhrv. but when I import pyhrv, I get com.chaquo.python.PyException: ModuleNotFoundError: No module named 'tkinter' (Even if I don't put any funtion of pyhrv, just only import pyhrv, it says same error)

I know chaquopy doesn't support tkinter. But I don't need to use tkinter. I don't use and write it anywhere. Is pyhrv using tkinter??? Is pyhrv related to tkinter?

Why does pyhrv out tkinter error although I don't use tkinter? And how can I use pyhrv without tkinter error?

mhsmith commented 2 months ago

Please post the full stack trace, as described at https://stackoverflow.com/a/23353174.

ChaeYeon01 commented 2 months ago

Oh I'm so sorry..!

here:

pyhrv_cv1 pyhrv_cv2 pyhrv_cv3

mhsmith commented 2 months ago

I suggest you report this to the biosppy project, and request them to tolerate the situation where tkinter is unavailable.

Unfortunately I can't see any simple workaround. Adding a fake tkinter module to sys.modules isn't enough, because biosppy/inter_plotting/ecg.py also unconditionally imports matplotlib.backends.backend_tkagg, which itself imports many other tkinter modules and classes.