ImportError: no module named 'uasyncio'

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
snake77
Posts: 31
Joined: Thu Jun 24, 2021 11:26 pm

ImportError: no module named 'uasyncio'

Post by snake77 » Sun Jun 27, 2021 1:07 pm

When I try to import the module, I get:

Code: Select all

>>> import uasyncio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'uasyncio'
It's also not listed when I call the help command that I found in the docs:

Code: Select all

>>> help("modules")
__main__          inisetup          ucryptolib        usocket
_boot             lwip              uctypes           ussl
_onewire          machine           uerrno            ustruct
_webrepl          math              uhashlib          usys
apa102            micropython       uheapq            utime
btree             neopixel          uio               utimeq
builtins          network           ujson             uwebsocket
dht               ntptime           uos               uzlib
ds18x20           onewire           upip              webrepl
esp               port_diag         upip_utarfile     webrepl_setup
flashbdev         uarray            urandom           websocket_helper
framebuf          ubinascii         ure
gc                ucollections      uselect
Plus any modules on the filesystem
The ESP8266 has been flashed with the most recent firmware from the website:

Code: Select all

esp8266-1m-20210618-v1.16.bin
I couldn't find any further information in the docs. :( I guess I need to install the module? But why is it not there already? The docs say it's part of MicroPython stdlib.

snake77
Posts: 31
Joined: Thu Jun 24, 2021 11:26 pm

Re: ImportError: no module named 'uasyncio'

Post by snake77 » Sun Jun 27, 2021 1:49 pm

Okay, when I install it via upip, it works.

Code: Select all

import upip
upip.install("uasyncio")
However, I still don't understand why this was necessary. It isn't mentioned anywhere. Did I overlook something?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: ImportError: no module named 'uasyncio'

Post by pythoncoder » Mon Jun 28, 2021 9:09 am

Something is wrong there. Recent versions (1.5, 1.6) of firmware include uasyncio V3. Please ensure you are running either V1.6 or a daily build. It's well worth ensuring you have V3 which fixes a lot of bugs. To check it do this at the REPL:

Code: Select all

>>> import uasyncio
>>> uasyncio.__version__
(3, 0, 0)
Peter Hinch
Index to my micropython libraries.

snake77
Posts: 31
Joined: Thu Jun 24, 2021 11:26 pm

Re: ImportError: no module named 'uasyncio'

Post by snake77 » Mon Jun 28, 2021 9:38 am

pythoncoder wrote:
Mon Jun 28, 2021 9:09 am
Something is wrong there. Recent versions (1.5, 1.6) of firmware include uasyncio V3. Please ensure you are running either V1.6 or a daily build.
I connected via serial console, did a soft reboot with ^D and got the following output:

Code: Select all

>>> 
>>> 
MPY: soft reboot
MicroPython v1.16 on 2021-06-18; ESP module (1M) with ESP8266
Type "help()" for more information.
>>> import uasyncio
>>> uasyncio.__version__
(3, 0, 0)
>>> 
Note: This is the uasyncio from the lib folder, which was installed by upip. It was not automatically included.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: ImportError: no module named 'uasyncio'

Post by kevinkk525 » Mon Jun 28, 2021 10:30 am

It's possible that the 1M still doesn't include the module uasyncio? It was not included earlier but I remember having had a discussion about it.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

JennaSys
Posts: 33
Joined: Tue Jul 15, 2014 8:29 am
Location: Southern California, US
Contact:

Re: ImportError: no module named 'uasyncio'

Post by JennaSys » Tue Jul 27, 2021 12:16 am

I just went through this myself, and can confirm that the 1M build does NOT include uasyncio by default. It can be added with a custom build though.
John Sheehan

Post Reply