No Module named 'fastapi' – Ubuntu environment
Question:
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.
Uninstalled and reinstalled fastapi library
Answers:
- Maybe you are using the wrong env? It looks like you’re using vscode so you can specify the interpeter
- Try
pip install --upgrade pip
and then pip install fastapi again
- Try using conda, and do
conda install -c conda-forge fastapi
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
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.
Uninstalled and reinstalled fastapi library
- Maybe you are using the wrong env? It looks like you’re using vscode so you can specify the interpeter
- Try
pip install --upgrade pip
and thenpip install fastapi again
- Try using conda, and do
conda install -c conda-forge fastapi
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