I’m following the Flask tutorial here:
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
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:
ImportError: No module named flask
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. Then create a new virtualenv with:
Then:
Now let’s activate the virtualenv
Now you should see
(flask)
on the left of the command line.Edit: In windows there is no “source” that’s a linux thing, instead execute the activate.bat file, here I do it using Powershell: PS C:\DEV\aProject>
& .\Flask\Scripts\activate
)Let’s install flask:
Then create a file named
hello.py
(NOTE: seeUPDATE Flask 1.0.2
below):and run it with:
UPDATE Flask 1.0.2
With the new flask release there is no need to run the app from your script.
hello.py
should look like this now:and run it with:
Make sure to be inside the folder where
hello.py
is when running the latest command.All the steps before the creation of the hello.py apply for this case as well