bclayman bclayman - 7 months ago 227
Python Question

Flask ImportError: No Module Named Flask

I'm following the Flask tutorial here:


I get to the point where I try ./run.py and I get:

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: No module named flask

This looks similar to:


But their solutions aren't helpful. For reference, I do have a folder named flask which one user mentioned may cause issues.


try deleting the virtualenv you created. create a new virtualenv

virtualenv flask


cd flask

let's activate the virtualenv

source bin/activate

now you should see (flask) on the left of the command line. Let's install flask

pip install flask

Then create a file hello.py

from flask import Flask
app = Flask(__name__)

def hello():
    return "Hello World!"

if __name__ == "__main__":

and run it with

python hello.py