lvgl / lv_binding_micropython

LVGL binding for MicroPython
MIT License
250 stars 161 forks source link

micropython lv_binding_micropython/examples/fb_test.py #ImportError: no module named 'evdev' #119

Closed china-zhangdj closed 3 years ago

china-zhangdj commented 3 years ago

I compiled and installed lv_micropython on raspberrypi. When I executed "micropython lv_binding_micropython/examples/fb_test.py". I encountered an error: "ImportError: no module named'evdev'", but when I executed import evdev in the REPL, it did not Report an error, what caused this.

amirgon commented 3 years ago

Hi @china-zhangdj, evdev is a frozen module. There is a Micropython bug related to sys.path affecting importing of frozen modules: https://github.com/micropython/micropython/issues/6419

To work around this, you can try running Micropython without command line arguments, and then something like this:

import sys
sys.path.append('lib/lv_bindings/examples')
import fb_test
china-zhangdj commented 3 years ago

Thank you very much!

execute:

import sys
sys.path.append("")

can fix it.

example: test.mpy

#!/usr/bin/micropython
import sys
sys.path.append("")
import evdev
import lvgl as lv
import fb
amirgon commented 3 years ago

Yes adding sys.path.append("") is a simpler workaround, thank you for this suggestion.

I'm closing this issue.