PyInstaller and FastAPI (maximum recursion depth exceeded)

最后都变了- 提交于 2020-05-17 08:45:54

问题


I have a python service that uses fastapi as a web interface. I need to make an executable file and hence I am using PyInstaller.

I keep getting the following error:

File "..../miniconda3/lib/python3.7/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2912, in _load_package
    self._load_module(fqname, fp, buf, stuff)
File "..../miniconda3/lib/python3.7/site-packages/PyInstaller/lib/modulegraph/modulegraph.py", line 2093, in _load_module
    m = self._load_package(fqname, pathname, packagepath)

RecursionError: maximum recursion depth exceeded while calling a Python object

I added import sys; sys.setrecursionlimit(50000) to the original python file as well as in the spec but still getting the same problem.

The interesting thing is that I don't get that error if I don't use fastapi (It works with Flask for example). Looks like PyInstaller has some issue with fastapi.

Does anybody have any idea how to solve this issue?

This is the code in my main python function:

from fastapi import FastAPI
import uvicorn
app = FastAPI()

if __name__ == "__main__":
    uvicorn.run("main:app", host="0.0.0.0", workers=1, port=5000)

来源:https://stackoverflow.com/questions/61491358/pyinstaller-and-fastapi-maximum-recursion-depth-exceeded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!