Micropython ESP8266错误:AttributeError:“module”对象没有属性(在Python中工作正常)

2024-04-29 08:42:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用Micropython在ESP8266节点上用Thonny编写代码。 我设法用Micropython闪存芯片、连接、添加OLED显示器并运行我的第一个Hello World脚本。 然而,当我使用我以前尝试和测试过的一些Python代码时,我得到了一个AttributeError:'module'对象没有属性xyz错误。据我所知,这不应该是一个MicroPython vs python的问题,所以我有点不知所措

下面是抛出错误的main.py:

from machine import Pin, I2C
import ssd1306
from time import sleep
import tubestatus


# ESP8266 Pin assignment
i2c = I2C(-1, scl=Pin(5), sda=Pin(4))

oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)

while True:
    # Create a new status object for retrieving data
    current_status = tubestatus.Status()

    # Get a list of tube lines
    lines = current_status.list_lines()

    for line in lines:
        oled.text(line, 0, 0)
        oled.text(current_status.get_status(line).description, 0, 10)
        oled.show()
        time.sleep(3)        

import tubestatus指的是this超级简单(但工作正常)的github模块,该模块在ESP8266上可用(我假设是由main.py找到的,因为它似乎指的是模块中缺少的属性)

欢迎任何指点! 多谢各位

This shows the files on the device


Tags: 模块代码import属性status错误linemicropython