我无法在ESP32 Wroom板上运行状态机库“ upysm”,它是pysm的Micropython调整版本。
该板已连接到WLAN,并且我发出了以下命令,如文档中所示:
import upip
upip.install('upysm')
lib似乎已加载(我在/ lib文件夹中看到文件)并已安装:
Installing to: /lib/
Warning: micropython.org SSL certificate is not validated
Installing upysm 0.3.9 from https://files.pythonhosted.org/packages/4e/6d/c50d0ca1c6cf627830aaf1df619c18aa82519b0bceafa1f7b48a07c3032a/upysm-0.3.9.tar.gz
Installing micropython-collections.deque 0.1.3 from https://micropython.org/pi/collections.deque/collections.deque-0.1.3.tar.gz
Installing micropython-collections.defaultdict 0.3 from https://micropython.org/pi/collections.defaultdict/collections.defaultdict-0.3.tar.gz
Installing micropython-logging 0.3 from https://micropython.org/pi/logging/logging-0.3.tar.gz
Traceback (most recent call last):
File "boot.py", line 44, in <module>
File "boot.py", line 41, in initSystem
File "/lib/pysm/__init__.py", line 2, in <module>
File "/lib/pysm/pysm.py", line 93, in <module>
AttributeError: 'module' object has no attribute 'StreamHandler'
我要关注的最后一行。
现在我正尝试通过以下方式在main.py中使用该库:
from pysm import State, StateMachine, Event
on = State('on')
结果再次是错误:
Traceback (most recent call last):
File "main.py", line 13, in <module>
File "/lib/pysm/__init__.py", line 2, in <module>
File "/lib/pysm/pysm.py", line 93, in <module>
AttributeError: 'module' object has no attribute 'StreamHandler'
MicroPython v1.11-166-g9da46a98c on 2019-07-20; ESP32 module with ESP32
Type "help()" for more information.
>>> Running main.py
>>>
>>> Traceback (most recent call last):
File "<stdin>", line 15, in <module>
ImportError: no module named 'pysm.State'
看来我已经接近解决方案,但显然不够接近。
使其运行的最佳方法是什么?
我从头开始刷新,使用了官方文档中的示例代码