You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

chainlit run命令无法启动Python应用,提示文件不存在

Chainlit运行app.py报错:找不到chainlit_basics.py的解决办法

问题情况

我在App文件夹下有一个app.py文件,代码如下:

import chainlit as cl
from chainlit import user_session


@cl.on_message
async def main(message: cl.Message):
    # Your custom logic goes here...

    # Send a response back to the user
    await cl.Message(
        content=f"Received: {message.content}",
    ).send()

在macOS Sonoma的zsh终端执行chainlit run app.py -w时,收到错误:

Usage: chainlit run [OPTIONS] TARGET
Try 'chainlit run --help' for help.

Error: Invalid value: File does not exist: chainlit_basics.py

已确认chainlit包安装成功,chainlit hello可正常运行。

解决步骤

  • 检查chainlit配置文件:查看当前目录下的.chainlit/config.toml文件,若其中存在target = "chainlit_basics.py"的配置,将其修改为target = "app.py",或者直接删除该配置项,之后重新运行命令。
  • 确认工作目录:执行pwd命令验证当前终端路径是否为app.py所在的App文件夹,若不是,用cd App切换到对应目录后再执行运行命令。
  • 使用绝对路径运行:尝试用app.py的绝对路径执行命令,例如chainlit run /Users/xxx/App/app.py -w(替换成你的实际绝对路径),避免相对路径识别问题。
  • 重置chainlit配置:如果存在.chainlit文件夹,先删除它,再重新运行chainlit run app.py -w,让chainlit生成默认配置文件。

内容的提问来源于stack exchange,提问作者jarkow

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 21:14:54