Python: ImportError: No module named asyncio

Published: 2019-09-23 23:33:16 -0400 -0400

Reading time: 1 mins (119 words)

Tags: python asyncio import-error troubleshoot tutorial

problem

I’m trying to use asyncio in my Python program but it keeps failing with ImportError: No module named asyncio. asyncio is supposed to be a built-in library so why is this failing?

Here’s some example code I was able to reproduce it on:

import asyncio

async def main():
    print("running")

asyncio.run(main())

solution

You’re write, asyncio is a built-in library for Python versions 3.7+. So if you’re getting an error with the import, check your python version with python --version and make sure that you’re running at least version 3.7.

did this help?

I regularly post about tech topics I run into. You can get a periodic email containing updates on new posts and things I’ve built by subscribing here.

About the Ham

Hi I'm Hamilton and I wrote / built this! I like doing lots of things, but mostly I like to build (and then share those buildings). Some things I'm currently building: art, software, and prose. To stay up-to-date with my latest buildings, subscribe to my email list or follow one of my many other accounts. #buildit #shipit #justhamit

comments powered by Disqus