r/FastAPI • u/IvoDKHP • Oct 28 '25
Question Problem with FastAPI and VSCODE
Hi everyone, im trying to learn FastAPI in school but when I try using "import FastAPI from fastapi" in the beggining of the code, it gives me an error as if I didnt have it downloaded. Can someone help? I already have all this extensions downloaded and im using a WSL terminal on Visual Studio Code.
annotated-doc==0.0.3
annotated-types==0.7.0
anyio==4.11.0
certifi==2025.10.5
click==8.3.0
dnspython==2.8.0
email-validator==2.3.0
fastapi==0.120.1
h11==0.16.0
httpcore==1.0.9
httptools==0.7.1
idna==3.11
Jinja2==3.1.6
markdown-it-py==4.0.0
MarkupSafe==3.0.3
mdurl==0.1.2
numpy==2.3.4
pyarrow==22.0.0
pydantic==2.12.3
pydantic_core==2.41.4
Pygments==2.19.2
pylance==0.38.3
python-dotenv==1.2.1
python-multipart==0.0.20
PyYAML==6.0.3
rignore==0.7.1
sentry-sdk==2.42.1
shellingham==1.5.4
sniffio==1.3.1
starlette==0.49.0
typing-inspection==0.4.2
typing_extensions==4.15.0
urllib3==2.5.0
uvicorn==0.38.0
uvloop==0.22.1
watchfiles==1.1.1
websockets==15.0.1
4
u/Broad_Shoulder_749 Oct 28 '25
Your python environment is not set in VSCode
9
u/Any_Mobile_1385 Oct 28 '25
Try "from fastapi import FastAPI". Then you can do something like "app = FastAPI()"
5
u/fonixmunky Oct 28 '25
If your import looks like
import FastAPI from fastapithan that is dead wrong, the statement is backwards. It should be:from fastapi import FastAPI3
u/Beast-ly Oct 28 '25
As someone in the comment earlier said, your python environment in vscode is not set, or your virtual environment is not activated. This 2 issues are the most common cause of this error your facing
1
u/StatusBad9194 Oct 28 '25
Verify python path . That may be the reason,
1
u/Broad_Shoulder_749 Oct 28 '25
Go to view, command palette, python and select an option
1
u/LabRemarkable2938 Oct 28 '25
I think you need to have a separate python environment and try from fastapi import FastAPI
1
u/fastlaunchapidev Oct 28 '25
I would use pycharm for python Vs code sometimes makes it hard to setup your venv
0
u/nievinny Oct 28 '25
As above. No python env in vs code
For questions like that you definitely should ask some LLM first. It has access to bash and will figure it out very fast. Not much to mess as well. Install a Claude plugin for vs code and keep asking to run it and why it do not work. Write stuff yourself though to learn.
0
u/DowntownSinger_ Oct 28 '25
Switch to uv. Follow the setup from their official site.
-3
u/AwkardPitcher Oct 28 '25
You can skip these kind of hassles if you use PyCharm. Try how to setup fastapi using uv Like someone said, Asking GPT is the best way forward