python-periphery icon indicating copy to clipboard operation
python-periphery copied to clipboard

ImportError when trying to import LED from periphery module

Open goodniuniu opened this issue 1 year ago • 1 comments
trafficstars

Body:

Hello,

I've encountered an import error while trying to use the periphery library for controlling LEDs in a Python script. Below is the error message I received:

Traceback (most recent call last):
  File "/home/pico/github/epaper-with-raspberrypi/tmp/luckfox_led.py", line 1, in <module>
    from periphery import LED
ImportError: cannot import name 'LED' from 'periphery' (/home/pico/github/epaper-with-raspberrypi/venv/lib/python3.10/site-packages/periphery/__init__.py)

Steps to Reproduce:

  1. Create a Python script named luckfox_led.py with the following content:
    from periphery import LED
    # Additional code to manipulate LEDs
    
  2. Run the script using Python 3.10 in a virtual environment: python luckfox_led.py.

Expected Behavior:

The script should import the LED class from the periphery module without any issues, allowing further LED manipulation commands to be executed.

Actual Behavior:

An ImportError is raised, indicating that the LED class cannot be imported from the periphery module.

Environment:

  • Python version: 3.10
  • periphery version: [python-periphery 2.4.1]
  • Operating System: [Linux luckfox 5.10.110 #1 Fri Dec 29 14:34:18 HKT 2023 armv7l armv7l armv7l GNU/Linux]
  • Hardware: [luckfox pico max]

Any insights or solutions to resolve this import issue would be greatly appreciated. Thank you!


goodniuniu avatar Mar 06 '24 09:03 goodniuniu

I can't reproduce this in a venv. Could you have installed an old version of periphery? Can you check the contents of /home/pico/github/epaper-with-raspberrypi/venv/lib/python3.10/site-packages/periphery/__init__.py?

vsergeev avatar Mar 07 '25 11:03 vsergeev