Pyinstaller-compiled Uvicorn server does not start correctly

后端 未结 2 968
小蘑菇
小蘑菇 2021-01-22 17:52

When I start the server.exe and it is trying to perform uvicorn.run(), the exception is being thrown:

<         


        
2条回答
  •  广开言路
    2021-01-22 18:04

    I encountered the same problem. And I found it's a job of hiddenimports,It's useful to modify the following lines in xxx.spec:

    a = Analysis(['xxx.py'], 
                 hiddenimports=['uvicorn.logging'], 
                 )
    

    however, there will still be other similar problems. So, I try to add all files of uvicorn,and it works with:

    hiddenimports=['uvicorn.lifespan.off','uvicorn.lifespan.on','uvicorn.lifespan',
    'uvicorn.protocols.websockets.auto','uvicorn.protocols.websockets.wsproto_impl',
    'uvicorn.protocols.websockets_impl','uvicorn.protocols.http.auto',
    'uvicorn.protocols.http.h11_impl','uvicorn.protocols.http.httptools_impl',
    'uvicorn.protocols.websockets','uvicorn.protocols.http','uvicorn.protocols',
    'uvicorn.loops.auto','uvicorn.loops.asyncio','uvicorn.loops.uvloop','uvicorn.loops',
    'uvicorn.logging'],
    

    then, run:

    pyinstaller xxx.spec
    

提交回复
热议问题