Sanic example is not working
See original GitHub issueI get an error when starting tortoise-orm along with Sanic as an example Python 3.6 from this source https://github.com/tortoise/tortoise-orm/blob/develop/examples/sanic/main.py 1 - I installed everything according to the instructions. The package required installation separately
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1741, in <module>
main()
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/Sergey/Desktop/Projects/rush-sanic/main.py", line 5, in <module>
from tortoise.contrib.sanic import register_tortoise
File "/Users/Sergey/Desktop/Projects/rush-sanic/venv/lib/python3.6/site-packages/tortoise/contrib/sanic/__init__.py", line 6, in <module>
from tortoise import Tortoise
ImportError: cannot import name 'Tortoise'
2 - After install Tortoise separetly i have another problem:
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1741, in <module>
main()
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/Sergey/Desktop/Projects/rush-sanic/main.py", line 46, in <module>
port=app.config.PORT
File "/Users/Sergey/Desktop/Projects/rush-sanic/venv/lib/python3.6/site-packages/sanic/app.py", line 1135, in run
serve(**server_settings)
File "/Users/Sergey/Desktop/Projects/rush-sanic/venv/lib/python3.6/site-packages/sanic/server.py", line 775, in serve
trigger_events(before_start, loop)
File "/Users/Sergey/Desktop/Projects/rush-sanic/venv/lib/python3.6/site-packages/sanic/server.py", line 633, in trigger_events
loop.run_until_complete(result)
File "uvloop/loop.pyx", line 1417, in uvloop.loop.Loop.run_until_complete
File "/Users/Sergey/Desktop/Projects/rush-sanic/venv/lib/python3.6/site-packages/tortoise/contrib/sanic/__init__.py", line 78, in init_orm
await Tortoise.init(config=config, config_file=config_file, db_url=db_url, modules=modules)
AttributeError: type object 'Tortoise' has no attribute 'init'
type object ‘Tortoise’ has no attribute ‘init’
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Examples — Sanic 20.12.3 documentation - Read the Docs
This section of the documentation is a simple collection of example code that can help you get a quick start on your application...
Read more >Issues · sanic-org/sanic - GitHub
SanicException : Sanic app name "Example" not found. #2560 opened on Oct 7 by zx8 · 1 · AttributeError: 'NoneType' object has no...
Read more >ValueError when trying to run sanic in dev mode
I'm not sure why you can't just run sanic --dev server.app . I get the same error as you. However, running python -m...
Read more >The sanic.app run parameter has not been checked for port ...
I found a problem. When using the run method in sanic.app, if workers are not specified in the parameter ... What is an...
Read more >Sanic Application
Because this can create potential problems with name conflicts, ... This can be useful, for example, if you need to access your Sanic...
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
Friend, I’m very sorry. I finally got enough sleep and realized that I had a mistake while installing orm. I started an empty project, deleted all unnecessary dependencies and it worked;) Thank you very much for spending your time on me!
Why do I need to install
Tortoise
separately