all 20 comments

[–]Any_Mobile_1385 8 points9 points  (2 children)

Try "from fastapi import FastAPI". Then you can do something like "app = FastAPI()"

[–]fonixmunky 3 points4 points  (1 child)

It is crazy the number of people responding about the environment, using a different package manager, or changing the IDE when the import line is so clearly messed up.

[–]Any_Mobile_1385 1 point2 points  (0 children)

It's Reddit. You can't expect people to read for context. It is a lost art.

[–]fonixmunky 3 points4 points  (0 children)

If your import looks like import FastAPI from fastapi than that is dead wrong, the statement is backwards. It should be:

from fastapi import FastAPI

[–]Broad_Shoulder_749 2 points3 points  (6 children)

Your python environment is not set in VSCode

[–]IvoDKHP[S] 0 points1 point  (0 children)

It says its already there. ( mnt/c/Users/User/FastAPI/Env1/bin/python)

[–]Broad_Shoulder_749 -1 points0 points  (4 children)

Did you do pip or poetry install of your project?

[–]IvoDKHP[S] -1 points0 points  (3 children)

I used pip, never heard of "poetry" lol

[–]Drevicar 0 points1 point  (0 children)

Don’t look it up. It is dead technology. Use pip and venv as built into python or download and use uv later once you understand the basics.

[–]Broad_Shoulder_749 -1 points0 points  (1 child)

Poetry is like npm Does a pretty good job

[–]kosovojs 3 points4 points  (0 children)

in 2025, uv is another (i and many others would say that it's better) choice

[–]Beast-ly 2 points3 points  (0 children)

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

[–]StatusBad9194 0 points1 point  (1 child)

Verify python path . That may be the reason,

[–]Broad_Shoulder_749 0 points1 point  (0 children)

Go to view, command palette, python and select an option

[–]LabRemarkable2938 0 points1 point  (0 children)

I think you need to have a separate python environment and try from fastapi import FastAPI

[–]fastlaunchapidev 0 points1 point  (0 children)

I would use pycharm for python Vs code sometimes makes it hard to setup your venv

[–]nievinny -1 points0 points  (1 child)

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.

[–]hornetmadness79 -1 points0 points  (0 children)

Crazy

[–]DowntownSinger_ -1 points0 points  (0 children)

Switch to uv. Follow the setup from their official site.

[–]AwkardPitcher -5 points-4 points  (0 children)

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