诗歌脚本:找不到文件/文件夹
我目前正在使用FastApi建立后端,并且面临一些使用诗歌脚本来运行后端的问题。这是我的项目结构:
├── backend
└── src
└── asgi.py
└── Dockerfile
└── poetry.lock
└── pyproject.toml
pyproject.toml
[tool.poetry]
name = "backend"
version = "0.1.0"
description = ""
authors = ["Pierre-Alexandre35 <[email protected]>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.9"
uvicorn = "^0.17.6"
fastapi = "^0.78.0"
psycopg2 = "^2.9.3"
jwt = "^1.3.1"
python-multipart = "^0.0.5"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.scripts]
foo='asgi:__main__'
如果我正在运行诗歌运行python asgi.py.py
,它的工作正常,但是如果我使用poetry foo 脚本,我得到
未找到包装后端的文件/文件夹
。这些都是我尝试过的组合,我对每个诗歌都有相同的错误
:
foo='asgi:main'
foo='backend.asgi:__main__'
foo='backend.asgi:main'
foo='backend.asgi:.'
I am currently building a backend using FastAPI and I am facing some issues to run the backend using poetry scripts. This is my project structure:
├── backend
└── src
└── asgi.py
└── Dockerfile
└── poetry.lock
└── pyproject.toml
pyproject.toml
[tool.poetry]
name = "backend"
version = "0.1.0"
description = ""
authors = ["Pierre-Alexandre35 <[email protected]>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.9"
uvicorn = "^0.17.6"
fastapi = "^0.78.0"
psycopg2 = "^2.9.3"
jwt = "^1.3.1"
python-multipart = "^0.0.5"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.scripts]
foo='asgi:__main__'
If I am running poetry run python asgi.py
, it is working perfectly but if I am using poetry foo
script, I am getting No file/folder found for package backend
. Those are all combinaisons I tried and I have the same error for every poetry run foo
:
foo='asgi:main'
foo='backend.asgi:__main__'
foo='backend.asgi:main'
foo='backend.asgi:.'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的项目结构似乎是不正确的。假设
后端
是您正在尝试创建的软件包。在脚本使用中也使用此结构
。 (假设您试图使用 Main 使用
foo
)Your project structure does not seem to be correct. Assuming
backend
is the package u are trying to create.Use this structure
Also in scripts use. (Assuming you are trying to run main with
foo
)