I am following the tutorial here.
My file looks like this:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def main():
return "Welcome!"
if __name__ == "__main__":
app.run()
I run python app.py
and get the following:
Traceback (most recent call last):
File "app.py", line 1, in <module>
from flask import Flask
ImportError: No module named Flask
I do have flask installed. I was thinking it's a $PATH issue. I don't really know where to begin as far as troubleshooting goes.
which flask
gives me:
/usr/local/bin/flask
which python
gives me:
/usr/bin/python
Any help is much appreciated, there are other similar issues out there but those solutions have not helped. Happy to answer any questions. Thank you.
Answers to questions:
Q. Which Python version? A. Python 2.7.10
Q. How did you install Flask? A. pip install flask
Second solution is First of all just create a new virtualenv with this command: virtualenv flask Then open it with: cd flask. Now you have to activate the virtualenv with this command: source bin/activate. Now just install flask: pip install flask. Now your error must be solved.
before run your app.py you need to activate your server by this command
. venv/bin/activate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With