peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
575 stars 126 forks source link

Error 'module' object has no attribute 'Lock' #43

Closed poerob closed 4 years ago

poerob commented 4 years ago

Hello,

i tried to install and use the resilient mqtt library. As you described in your Guide, i installed uasyncio, uasyncio.synchro and uasyncio.queues Link and copied mqtt_as.py and config.py via mpfshell to the root directory. Unfortunately, im stuck with the error "'module' object has no attribute 'Lock'" when i call a test script. Looking at the code in mqtt_as, it seems this error comes from lock being not found in uasyncio. Can you help me with that?

Anyway, thank you for the effort to create a resilient mqtt lib and the great documentation. I can't wait to start working with the library.

kevinkk525 commented 4 years ago

The library got updated to support the new uasyncio version 3.0.0 that got merged in to micropython recently. If you use a daily build of the micropython firmware you don't need to install uasyncio and can remove all those module you installed. If you are running an older version of micropython or want to keep using the old uasyncio version, then use this version of mqtt_as (before the commit that updated it to the new uasyncio version): https://github.com/peterhinch/micropython-mqtt/blob/ff6b5aa3121de1ea9ca6436f535f0817105cfadd/mqtt_as/mqtt_as.py

poerob commented 4 years ago

Hi kevin, thank you for your fast reply! Indeed, i did not use a daily build but a version from 2019 Link. I did not use the latest build by accident, thank you for the hint.

Even if this has nothing todo with the mqtt lib, installing uasyncio via upip leads to a old uasyncio version from June 2019 Link compared to the latest available in the micropython GitHub Repo. Is that intention?

poerob commented 4 years ago

Just updated the Controller and now everything works fine. Thanks for the fast help!

kevinkk525 commented 4 years ago

Glad you got it sorted out.

Even if this has nothing todo with the mqtt lib, installing uasyncio via upip leads to a old uasyncio version from June 2019 Link compared to the latest available in the micropython GitHub Repo. Is that intention?

The version on pypip is not an official uasyncio version and doesn't even work on the official micropython. It's out of the control of the micropython contributors.

peterhinch commented 4 years ago

@kevinkk525 Just FYI that issue was fixed a while ago: upip first searches a database maintained by Damien, only if an item is not found does it look on PyPi. Consequently

upip.install('micropython-uasyncio')

will install the old, official uasyncio (unless it's an old version of upip).

kevinkk525 commented 4 years ago

Oh, thanks! I forgot upip was fixed that way by Damien. That's good.