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

运行setup.cfg中console_scripts入口点报缺少位置参数错误如何解决

问题原因

你当前的报错是因为直接将ASGI应用实例app设置为了console脚本的入口点:ASGI应用(FastAPI/Starlette等框架生成的app)的__call__方法是专门给ASGI服务器(如uvicorn)调用的,要求必须传入scope、receive、send三个位置参数,不能直接作为脚本入口函数执行。
另外你写在if __name__ == "__main__"下的uvicorn启动代码,只会在直接执行python prediction_engine.py时触发,通过console_script入口点调用时不会运行该段逻辑,因此也没有启动uvicorn来托管app。

解决方案

推荐采用自定义启动函数的方案,操作如下:

  1. 在prediction_engine.py文件中新增独立的启动函数,修改后代码示例:
import uvicorn
# 保留你原有app的定义代码
app = FastAPI() # 你的原有app定义

# 新增启动函数
def start_server():
    uvicorn.run(
        "prediction_engine.prediction_engine:app",
        host="0.0.0.0",
        port=8888,
        reload=True,
        log_level="info"
    )

if __name__ == "__main__":
    start_server()
  1. 修改setup.cfg的入口点配置,指向新增的启动函数:
[options.entry_points]
console_scripts =
  start-prediction-engine = prediction_engine.prediction_engine:start_server
  1. 重新安装你的包生效配置,比如开发模式安装执行:
    pip install -e .
    修改完成后再执行start-prediction-engine即可正常启动服务。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.04 23:36:03