【发布时间】:2021-11-24 11:31:26
【问题描述】:
我正在学习fastapi。我有一个像这样的非常简单的项目结构
.
├── __init__.py
├── database.py
├── main.py
├── models.py
├── requirements.txt
└── schemas.py
main.py 里面是
from fastapi import FastAPI
from typing import Optional
from . import schemas, models
from .database import engine
app = FastAPI()
# more code here...
但是当我使用uvicorn main:app --reload 运行它时,我得到了错误
...
从 。导入模式、模型
ImportError: 在没有已知父包的情况下尝试相对导入
我不明白为什么会出现此错误。我正在松散地关注this tutorial。我还阅读了许多相关的 SO 问题(123),但似乎没有一个符合我的情况。
【问题讨论】:
标签: python python-import fastapi