Search code examples
python-3.xubuntu-16.04fastapiuvicorn

Python interpretor returns error for FASTAPI - **extra: Any,


I'm having trouble executing fastapi under WSL. I'm using:

  • WSL2
  • Ubuntu 16.04.7 LTS
  • Python 3.5.2 (using Visual Studio Code interpretor)
  • fastapi - 0.73.0
  • uvicorn - 0.8.6

I'm getting an error when I execute the uvicorn command -

**extra: Any,

  • see attached image.

I'm stuck on this for a while so any ideas would be strongly appreciated.

I tried updating python interpretor to newer version (3.9) but for some reason I did not succeed - see pls the second attached screenshot.

enter image description here

enter image description here


Solution

  • FastAPI requires python 3.6 and won't work with Python 3.5 as you've found out.

    The ubuntu version you're using does not have a new enough Python version by default. You can either install a more recent Python version in Windows, upgrade your Ubuntu version or use the deadsnakes ppa to get access to newer versions of Python on older Ubuntu versions (or the other way around if you need old Python versions on more recent versions of Ubuntu).