Install & Compatibility
Where this runs
tested against v0.16 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.218s · 18.5MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.208s · 19MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SerialTransport
✓ import serial_asyncio_fast as s; s.SerialTransport
✗ from serial_asyncio import SerialTransport
Wrong package: pyserial-asyncio (old) vs pyserial-asyncio-fast
create_serial_connection
✓ from serial_asyncio_fast import create_serial_connection
✗ from serial_asyncio import create_serial_connection
Wrong package: pyserial-asyncio (old) vs pyserial-asyncio-fast
Open a serial connection and read/write asynchronously.
import asyncio
import serial_asyncio_fast
async def main():
reader, writer = await serial_asyncio_fast.open_serial_connection(url='/dev/ttyUSB0', baudrate=115200)
writer.write(b'hello')
data = await reader.read(100)
print(data)
writer.close()
asyncio.run(main())
Debug
Known issues
deprecatedpyserial-asyncio (original) is deprecated. Use pyserial-asyncio-fast (faster, maintained).fixpip install pyserial-asyncio-fast and change imports from 'serial_asyncio' to 'serial_asyncio_fast'.
affects: pyserial-asyncio all versions
gotchaopen_serial_connection returns (asyncio.StreamReader, asyncio.StreamWriter), not a custom transport. Writers must be explicitly closed.fixAlways call writer.close() after use, ideally in a try/finally block.
affects: all versions
gotchaThe package uses 'serial_asyncio_fast' (with underscore), not 'serial-asyncio-fast' (hyphen). Common import error.fixUse 'import serial_asyncio_fast' (underscores).
affects: all versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'serial_asyncio'
Installed the wrong package or used the old import path.
fixInstall pyserial-asyncio-fast and use 'import serial_asyncio_fast' (underscores).
AttributeError: module 'serial_asyncio_fast' has no attribute 'create_serial_connection'
Function may be named 'open_serial_connection' in this version.
fixUse 'serial_asyncio_fast.open_serial_connection' instead.
NotImplementedError: Event loop is not running
Called async function outside of an asyncio event loop.
fixWrap the call in asyncio.run() or run within a running loop.
Upgrade
Version history
0.16latest on PyPI · released Mar 27, 2025
Audit
Dependencies
pyserialrequiredCore serial port library