I'm newbie. I try to install and run sanic as the example
in sanic.py:
from sanic import Sanic
from sanic.response import text
app = Sanic(__name__)
@app.route("/")
async def test(request):
return text('Hello world!')
app.run(host="0.0.0.0", port=8000, debug=True)
in bash, i try to run it, but cause this error:
cabox@box-codeanywhere:~/workspace$ sudo python3.5 -m pip install sanic
Requirement already satisfied (use --upgrade to upgrade): sanic in /usr/local/lib/python3.5/dist-packages
Cleaning up...
cabox@box-codeanywhere:~/workspace$ python3.5 sanic.py
Traceback (most recent call last):
File "sanic.py", line 1, in <module>
from sanic import Sanic
File "/home/cabox/workspace/sanic.py", line 1, in <module>
from sanic import Sanic
ImportError: cannot import name 'Sanic'
this is my environment:
python3 = python3.4
python3.5=python3.5
Please Help
Name your file something other than sanic.py
The problem was identified. Can this issue be closed?
Sometimes it caused by Python Environment.
Ex:
I built Python3.7 and pip3.
I installed sanic via pip3.
Probably python3 is not the same as python3.7.
$ which python3
$ which python3.7
$ # or
$ python3 --version
$ python3.7 --version
Most helpful comment
Name your file something other than
sanic.py