cannot import name '_input' from partially initialized module 'evdev' (most likely due to a circular import)
A plugin for an open source [smart home controller](https://www.candlesmarthome.com) I'm working on works on a slightly older version of the controller (Python 3.9.2), but fails on a newer one (Python 3.11.2).
```
~/.webthings/addons/buttoninput $ python3 main.py
Traceback (most recent call last):
File "/home/pi/.webthings/addons/buttoninput/main.py", line 12, in <module>
from pkg.buttoninput import ButtonInputAdapter # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.webthings/addons/buttoninput/pkg/buttoninput.py", line 28, in <module>
import evdev
File "/home/pi/.webthings/addons/buttoninput/lib/evdev/__init__.py", line 13, in <module>
from .device import (
File "/home/pi/.webthings/addons/buttoninput/lib/evdev/device.py", line 5, in <module>
from . import _input, ecodes, util
ImportError: cannot import name '_input' from partially initialized module 'evdev' (most likely due to a circular import) (/home/pi/.webthings/addons/buttoninput/lib/evdev/__init__.py)
```
The main code of my plugin can be [found here](https://github.com/createcandle/buttoninput/blob/main/pkg/buttoninput.py).
I'm not a professional developer. Any hints on where I should look to debug this?
// I do not see a file called `_input.py` in the module.

关闭于 2025-05-07 3 条评论