AnaviTechnology / anavi-examples

Examples for getting started and testing ANAVI Internet of Things and add-on boards (HAT & pHAT) for Raspberry Pi
MIT License
47 stars 19 forks source link

No module named: luma.oled #11

Closed MoJeeza closed 1 month ago

MoJeeza commented 2 months ago

Taking the example given on this repository - into Thonny on Rpi5 with Python 3.11 in a virtual env and after installing luma.core package I get the following error:

%Run -c $EDITOR_CONTENT Traceback (most recent call last): File "<string>", line 5, in <module> ModuleNotFoundError: No module named 'luma.oled' Any suggestions?

leon-anavi commented 2 months ago

Hi @MoJeeza,

Have you installed the luma.oled Python3 library? As mentioned in Info uHAT docs it can be done with the following command:

pip3 install --upgrade luma.oled

Which example are you trying to get working?

Best regards, Leon

MoJeeza commented 2 months ago

Thanks for the response...yes that solved the problem but now getting: `>> %Run testing_oled.py Unexpected error: <class 'OSError'>

Process ended with exit code 2. ` it is for this example code:

https://github.com/AnaviTechnology/anavi-examples/blob/master/peripherals/OLED-SSD1306/python/OLED-SSD1306.py

I don't see os When I try to find the package in Thonny. Isn't OS a built-in library for Python3?

MoJeeza commented 2 months ago

OK, I found the issue: It's with this line: drawfont = "pixelmix.ttf"

where should this file be? I tried putting it in the same folder as the .py file and I also added the full path to the filename and no luck

leon-anavi commented 2 months ago

OK, I found the issue: It's with this line: drawfont = "pixelmix.ttf"

where should this file be? I tried putting it in the same folder as the .py file and I also added the full path to the filename and no luck

Same directory where the Python script is, just like it is here: https://github.com/AnaviTechnology/anavi-examples/tree/master/peripherals/OLED-SSD1306/python

Best regards, Leon

MoJeeza commented 2 months ago

/Documents/python/RPi/RPi5 $ python3 testing_oled.py Unexpected error: <class 'OSError'>

4x16_segment_led_test.py testing_led_blink.py testing_oled.py pixelmix.ttf testing_led_blink_v2.py

Even when I run it as an executable script: /Documents/python/RPi/RPi5 $ ./testing_oled.py Unexpected error: <class 'OSError'>

I tried with all three options: drawfont = "pixelmix.ttf"

drawfont = "/home/xxx/Documents/python/RPi/RPi5/pixelmix.ttf"

drawfont = "./pixelmix.ttf"

No luck...both files in the same directory

leon-anavi commented 2 months ago

Once you have cloned the repository and installed all dependencies, you need to run the Python3 script to show information on the OLED display:

cd ~/anavi-examples/peripherals/OLED-SSD1306/python/
python3 OLED-SSD1306.py

The IP address and "Hello, World!" will be shown on the display. Press Ctrl+C to terminate the Python3 script and clear the display.

More details are available at ANAVI Info uHAT user's manual: https://github.com/AnaviTechnology/anavi-docs/blob/main/anavi-info-uhat/anavi-info-uhat.md#python

Please note that testing_oled.py from your logs is not part of this repository and I cannot comment as I have no idea what is the source code of this script.