---
title: "uvicorn: 相对导入问题"
description: "应用结构:"
canonical_url: "https://yangqiuyi.com/blog/kai-fa/uvicorn-xiang-dui-dao-ru-wen-ti"
---

> Index of every page on this site: [llms.txt](https://yangqiuyi.com/llms.txt)

应用结构:

```text
.
├── app     # ①: 应用所在文件夹
│   ├── __init__.py
│   ├── main.py
│   ├── dependencies.py
│   └── routers
│   │   ├── __init__.py
│   │   ├── items.py
│   │   └── users.py
│   └── internal
│       ├── __init__.py
│       └── admin.py
```

错误的:

```sh
uvicorn main:app
```

正确的:

```sh
cd ..
uvicorn app.main:app
```

app.main:app, 第一个app表示应用所在文件夹的名称(①)
也就是说你必须要退出去一个目录才可以...

## Sitemap

See the full [sitemap](https://yangqiuyi.com/sitemap.md) for all pages.
