ModuleNotFoundError:没有名为';fast api';的模块 [英] ModuleNotFoundError: No module named 'fastapi'
本文介绍了ModuleNotFoundError:没有名为';fast api';的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我的文件结构和要求。txt:
正在获取ModuleNotFoundError
,如有任何帮助,我们将不胜感激。
main.py
from fastapi import FastAPI
from .import models
from .database import engine
from .routers import ratings
models.Base.metadata.create_all(bind=engine)
app = FastAPI()
app.include_router(ratings.router)
推荐答案
错误源于您在VSCODE上使用的环境和版本不正确。 您的环境知道您的不同包,但VSCode可能没有将它们考虑在内。
解决方案是,在VSCODE:CTRL + SHIFT + P
中,然后Python:select interpreter
并选择链接到您的环境的Python版本。
您可以尝试更改Python的版本,以查看导入的结果
这篇关于ModuleNotFoundError:没有名为';fast api';的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文