2

I'm following along with a Flask tutorial, and I'm creating a run.py file, running chmod a+x run.py, and running the file as ./run.py.

Unfortunately, I get this:

Traceback (most recent call last):
  File "./run.py", line 3, in <module>
    from app import app
  File "/Users/benjaminclayman/Desktop/microblog/app/__init__.py", line 1, in <module>
    from flask import Flask
ImportError: cannot import name Flask

For reference, my run.py file is:

#!flask/bin/python
from app import app
app.run(debug=True)

And when I run

from flask import Flask

there's no issue (I don't get any error message).

I looked at similar issues on SO and it looks like often it was having a file called flask.py but I don't have one (AFAIK).

Any idea what I did incorrectly?

Celeo
  • 5,583
  • 8
  • 39
  • 41
anon_swe
  • 8,791
  • 24
  • 85
  • 145
  • Near duplicate of [what is the significance of “ #!flask/bin/python ” in flask?](https://stackoverflow.com/questions/30954599/what-is-the-significance-of-flask-bin-python-in-flask) – smci Jul 02 '15 at 20:26

1 Answers1

3

Make your shebang

#!/usr/bin/env python

and run again. See this question.

Community
  • 1
  • 1
Celeo
  • 5,583
  • 8
  • 39
  • 41
  • also [what is the significance of “ #!flask/bin/python ” in flask?](https://stackoverflow.com/questions/30954599/what-is-the-significance-of-flask-bin-python-in-flask) – smci Jul 02 '15 at 20:27