rm-hull / luma.oled

Python module to drive a SSD1306 / SSD1309 / SSD1322 / SSD1325 / SSD1327 / SSD1331 / SSD1351 / SH1106 OLED
https://luma-oled.readthedocs.io
MIT License
807 stars 161 forks source link

ImportError: cannot import name 'sh1107' from 'luma.oled.device' #384

Closed outdoorbits closed 11 months ago

outdoorbits commented 11 months ago

At first thank you for this project, it takes an important role on my project https://github.com/outdoorbits/little-backup-box. Since Paspberry Pi OS bookworm I have the following problem: My former installation by sudo -H pip3 install luma.oled breaks now:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    For more information visit http://rptl.io/venv

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Then I found, the luma packages are in the repository now. So I installed: sudo apt install python3-luma.core python3-luma.emulator python3-luma.lcd python3-luma.led-matrix python3-luma.oled

But my script

...
from luma.core.interface.serial import i2c, spi, pcf8574
from luma.core.interface.parallel import bitbang_6800
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1309, ssd1325, ssd1331, sh1106, sh1107, ws0010
...

breaks, giving this error: ImportError: cannot import name 'sh1107' from 'luma.oled.device' (/usr/lib/python3/dist-packages/luma/oled/device/__init__.py)

In the documentation sh1107 is still available, but not into the module.

Thank you!

Type of Raspberry Pi

RPi 4B 8GB

Linux Kernel version

5.15.0-86-generic #96-Ubuntu SMP Wed Sep 20 08:23:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Expected behaviour

import the modules

Actual behaviour

script breaks

thijstriemstra commented 11 months ago

@outdoorbits I would make a virtual environment first, e.g.:

python3 -m venv ~/luma-venv

And then install luma.oled using:

~/luma-venv/bin/python -m pip install luma.oled

And exectute your scripts using that python, e.g.

~/luma-venv/bin/python /path/to/script.py

Looks like the docs need to be updated..