No module named lvgl

Hello,

Trying to run my first Python LVGL project on Raspberry Pi. I cloned everything from lv_micropython repository.

Went through steps below without problems:

  1. git clone --recurse-submodules https://github.com/littlevgl/lv_micropython.git
  2. cd lv_micropython
  3. make -C mpy-cross
  4. make -C ports/unix/
  5. ./ports/unix/micropython

Have created ttt.py file with content:

import lvgl as lv
lv.init()

import SDL
SDL.init()


# Register SDL display driver.

disp_buf1 = lv.disp_buf_t()
buf1_1 = bytearray(480*10)
disp_buf1.init(buf1_1, None, len(buf1_1)//4)
disp_drv = lv.disp_drv_t()
disp_drv.init()
disp_drv.buffer = disp_buf1
disp_drv.flush_cb = SDL.monitor_flush
disp_drv.hor_res = 480
disp_drv.ver_res = 320
disp_drv.register()

# Regsiter SDL mouse driver

indev_drv = lv.indev_drv_t()
indev_drv.init() 
indev_drv.type = lv.INDEV_TYPE.POINTER;
indev_drv.read_cb = SDL.mouse_read;
indev_drv.register();

Run ./micropython ttt.py and have seen small window for second.

Run debugger pdb ttt.py and got error:
ImportError: ‘No module named lvgl’

How to tell python where lvgl module is located? I don’t see any lvgl modules in /lv_micropython/ports/unix folder.

I assume pdb is the Python debugger. That’s most likely running your system’s native Python interpreter, and will not work with MicroPython. You would need to research a MicroPython equivalent, and I’m not sure that one exists, as MicroPython programs are generally not complex enough to require a full, sophisticated debugger.

Yes, you are right pdb is Python debugger from my Raspberry Pi system in which I’m trying to run code. I suppose I could try to run and debug my LVGL application with standard Python? How to tell Python about my LVGL library in this situation?

Unfortunately you can’t do that. The LVGL binding only works with MicroPython, not standard Python.

Your script does not wait so it exists immediately.
You can either add an infinite loop at the end, or run it with micropython -i which runs the script and then opens the interactive REPL instead of exiting.

As @embeddedt already mentioned - you cannot use pdb (or any other Python tool) with Micropython.

As far as I know there is no Micropython debugger.
sys.settrace is implemented so it’s possible to get a trace of the run. But Micropython core is inherently missing the ability to query/reflect local variables so a true debugger cannot be implemented for now.

See also: