使用manage-fastapi执行fastapi run时遇FileNotFoundError错误求助
问题
使用manage-fastapi创建FastAPI项目后,执行fastapi run命令时触发如下错误:
1491, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ FileNotFoundError: [WinError 2] The system cannot find the file specified
解决方案
- 改用Python模块方式启动:替换命令为
python -m fastapi run(Windows环境可尝试py -m fastapi run),绕开路径查找问题。 - 确认虚拟环境激活状态:如果项目使用了虚拟环境,先激活对应环境再执行启动命令。
- 重装相关依赖:卸载并重新安装包,执行以下命令:
pip uninstall -y manage-fastapi fastapi uvicorn pip install manage-fastapi fastapi uvicorn - 检查项目配置文件:查看项目内的
manage-fastapi配置文件(如pyproject.toml),确认启动配置里的可执行文件路径无拼写错误。
内容的提问来源于stack exchange,提问作者code_10
相关产品推荐
相关产品推荐

