Closed chongtwo closed 3 years ago
Thanks for the report, i don't know about this one but one thing I can see which might help you is that your sanic version is outdated, could try version 20.12.3 which is the latest from the 2012 release,
would also recommend to try with sanic 18.12 and sanic 21.3 and see if either of those work
if not i could help you debug it if you share a small code sample which can recreate it
Will close this but please do re-open if that doesn't solve your problem
I've tried your suggestion but it didn't work. The code is as below:
# sanic-openapi-test.py
from sanic import Sanic
from sanic.response import json
from sanic_openapi import swagger_blueprint
app = Sanic(name="sanic_openapi_test")
app.blueprint(swagger_blueprint)
@app.route("/")
async def test(request):
return json({"hello": "world"})
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
And I packaged the code by PyInstaller (pip install pyinstaller)
pyinstaller sanic-openapi-test.py
Went into the dist directory that is made by the command above and ran the sanic_openapi_test.exe. The error appeared:
Traceback (most recent call last):
File "sanic_openapi_test.py", line 6, in <module>
File "sanic\app.py", line 421, in blueprint
File "sanic\blueprints.py", line 234, in register
File "sanic\app.py", line 345, in _apply_static
File "sanic\mixins\routes.py", line 803, in _register_static
File "sanic\mixins\routes.py", line 155, in decorator
File "sanic\app.py", line 335, in _apply_route
File "sanic\router.py", line 128, in add
File "sanic_routing\router.py", line 170, in add
File "sanic_routing\route.py", line 115, in add_handler
sanic_routing.exceptions.RouteExists: Route already registered: swagger/<__file_uri__> [GET]
[6444] Failed to execute script sanic_openapi_test
Hope you can help me solve this problem. Thanks!
sanic 20.12.2 sanci-openapi 0.6.2 centos 7.4
When I run my project through pycharm all work fine, but when I package my project through pyinstaller and try to run the exe it cracks with the message that
I have seen #216 but it doesn't seem to help.