skip to Main Content

Though I have pip and pip3 installed fastapi library in my Ubuntu based workstation, I get a weird error saying

No module named ‘fastapi’.

I have been scratching my head since two days ago as the same code works in other laptop with same Ubuntu environment.

enter image description here

Uninstalled and reinstalled fastapi library

2

Answers


    1. Maybe you are using the wrong env? It looks like you’re using vscode so you can specify the interpeter
    2. Try pip install --upgrade pip and then pip install fastapi again
    3. Try using conda, and do conda install -c conda-forge fastapi
    Login or Signup to reply.
  1. you’re not using the correct environment to run your code.
    Either, 1. install the package fast-api in the environment you running the code in or 2. switch to the other one the packages are installed in:

    for 1:
    sudo /bin/python3 -m pip install "fastapi[all]"

    in this case you should be able to use the fast-api package
    Note: the other packages you use are probably not installed as well

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search