Sanic: ImportError: cannot import name 'Sanic'

Created on 5 Jan 2017  路  4Comments  路  Source: sanic-org/sanic

Hello all.
I'm newbie.
I installed this module.

pip3.5 show sanic

Name: Sanic
Version: 0.1.9
Summary: A microframework based on uvloop, httptools, and learnings of flask
Home-page: http://github.com/channelcat/sanic/
Author: Channel Cat
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.5/site-packages
Requires: uvloop, httptools, ujson, aiofiles, multidict

example code: (sanic.py)

from sanic import Sanic
from sanic.response import json

app = Sanic(__name__)


@app.route("/")
async def test(request):
    return json({"test": True})


app.run(host="0.0.0.0", port=8000)

Start, I get the error:
python3.5 sanic.py

Traceback (most recent call last):
  File "sanic.py", line 1, in <module>
    from sanic import Sanic
  File "/var/www/html/sanic.py", line 1, in <module>
    from sanic import Sanic
ImportError: cannot import name 'Sanic'

What am I doing wrong?

P.S. Flask runs without errors.

question

Most helpful comment

Try again after changing your own code's filename to whatever except sanic.py.

All 4 comments

How did you go about installing Sanic?

centos 6.8

just run
pip3.5 install sanic

Try again after changing your own code's filename to whatever except sanic.py.

@yoloseem Thanks 馃槀

Was this page helpful?
0 / 5 - 0 ratings