question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can not run `--dev` from SANIC CLI on windows

See original GitHub issue

Describe the bug while running sanic --dev server.app occures an error:

Error while finding module specification for '__main__' (ValueError: __main__.__spec__ is None)

Code snippet server.py

from sanic import Sanic
from sanic.response import text

app = Sanic("MyHelloWorldApp")


@app.get("/")
async def hello_world(request):
    return text("Hello, world.")

Expected behavior A clear and concise description of what you expected to happen.

Environment (please complete the following information):

  • OS: windows 10
  • Version: latest sanic

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
ahopkinscommented, May 24, 2022

I need to investigate it more first. Meaning I need to get onto my windows laptop and see why the entry point is not working and whether it is an implementation issue or an OS issue.

2reactions
nattheriddle1commented, May 24, 2022

@prryplatypus Yes, using the --auto-reload flag is sufficient to produce the same error.

I just tried that workaround command on my first project (without any of the previous __init__.py workarounds) and it worked!

The other workaround, which I have been using since I cannot use the CLI, involves setting up my application.py file to serve the app when directly imported, like…

if __name__ == "__main__":
    app.run(auto_reload=True)

…and then running python application.py or python -m application on the command line.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sanic app not working on windows - Moving forward
I am trying to run the basic sanic app on windows 10. But it is just stuck there showing this warning
Read more >
Running Sanic
There are two main ways to run Sanic Server: Using app.run; Using the CLI. When using app.run you will just call your Python...
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 >
cannot import name 'CompositionView' from 'sanic.views'
Rasa Open Source version 3.0.4 Rasa SDK version No response Rasa X version No response Python version 3.7 What operating system are you ......
Read more >
Sanic | Build fast. Run fast. — Sanic 22.9.1 documentation
Sanic makes use of uvloop and ujson to help with performance. If you do not want to use those packages, simply add an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found