sanic-ext is not working
See original GitHub issueDescribe the bug I am trying to run sanic and sanic-ext to check OpenAPI documentation. But the server shows an error message. If I remove sanic-ext, it runs correctly. I used sample hello world code from here https://sanic.dev/en/guide/getting-started.html#install
Code snippet
I installed sanic using poetry
poetry add sanic sanic-ext
Expected behavior Run server and open documentation
Environment (please complete the following information):
- Sanic (21.12.1)
- Sanic-ext(21.12.1 and 21.12.3)
Additional context
2022-01-11 12:48:29 -0500] [13508] [WARNING] Sanic is running in PRODUCTION mode. Consider using '--debug' or '--dev' while actively developing your application.
[2022-01-11 12:48:29 -0500] [13508] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/app.py", line 1204, in run
serve_single(server_settings)
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/server/runners.py", line 206, in serve_single
serve(**server_settings)
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/server/runners.py", line 120, in serve
setup_ext(app)
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/application/ext.py", line 23, in setup_ext
sanic_ext = import_module("sanic_ext")
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/__init__.py", line 1, in <module>
from sanic_ext.bootstrap import Extend
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/bootstrap.py", line 14, in <module>
from sanic_ext.extensions.http.extension import HTTPExtension
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/http/extension.py", line 4, in <module>
from .methods import add_auto_handlers, add_http_methods
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/http/methods.py", line 11, in <module>
from ..openapi import openapi
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/openapi/openapi.py", line 24, in <module>
from sanic_ext.extensions.openapi.builders import (
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/openapi/builders.py", line 18, in <module>
from .definitions import (
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/openapi/definitions.py", line 14, in <module>
from .types import Definition, Schema
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/openapi/types.py", line 6, in <module>
from typing import (
ImportError: cannot import name 'get_args' from 'typing' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py)
Traceback (most recent call last):
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/bin/sanic", line 8, in <module>
sys.exit(main())
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/__main__.py", line 12, in main
cli.run()
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/cli/app.py", line 77, in run
app.run(**kwargs)
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/app.py", line 1204, in run
serve_single(server_settings)
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/server/runners.py", line 206, in serve_single
serve(**server_settings)
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/server/runners.py", line 120, in serve
setup_ext(app)
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic/application/ext.py", line 23, in setup_ext
sanic_ext = import_module("sanic_ext")
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/__init__.py", line 1, in <module>
from sanic_ext.bootstrap import Extend
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/bootstrap.py", line 14, in <module>
from sanic_ext.extensions.http.extension import HTTPExtension
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/http/extension.py", line 4, in <module>
from .methods import add_auto_handlers, add_http_methods
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/http/methods.py", line 11, in <module>
from ..openapi import openapi
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/openapi/openapi.py", line 24, in <module>
from sanic_ext.extensions.openapi.builders import (
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/openapi/builders.py", line 18, in <module>
from .definitions import (
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/openapi/definitions.py", line 14, in <module>
from .types import Definition, Schema
File "/Users/jona/Library/Caches/pypoetry/virtualenvs/testrasa-D3I8zhmW-py3.7/lib/python3.7/site-packages/sanic_ext/extensions/openapi/types.py", line 6, in <module>
from typing import (
ImportError: cannot import name 'get_args' from 'typing' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py)
sys:1: RuntimeWarning: coroutine 'Loop.create_server' was never awaited
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Issues · sanic-org/sanic-ext - GitHub
Not all arguments are populated when validating multiple arguments enhancement New feature or request good first issue Good for newcomers help wanted Extra ......
Read more >Sanic-ext validate optional field not working - Questions and Help ...
Calling the API with query params ex: ?q=12345 will raise 400 error. without query params is fine Here's the sample code from dataclasses...
Read more >sanic-ext - PyPI
Sanic Extensions is still in ALPHA release. The API is not likely to change. It will move to BETA with v22.3.
Read more >Python Sanic ext 22.9.0 - Open API static YAML file loading
You have a few options. OPTION 1. Load your custom OAS into Sanic, and server that. @app.before_server_start async def load_oas(app: Sanic): ...
Read more >[Python] Agents not working with Sanic 21.9 or 21..12
I tried with a simple app with Sanic 21.6 and newrelic register traffic but not for the newest versions. APM Agent Language: Python;...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the information @ChihweiLHBird @ahopkins I upgraded python to 3.8 and it worked
Makes sense. Thanks for sharing 😎