Flask ImportError No Module Named Flask

0 votes

I followed this flask tutorial: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world.

I am getting this error at the part where I run ./run.py :

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

Can someone help me with this issue?

May 23, 2022 in Python by Kichu
• 19,040 points
2,432 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

What you have to do is to delete the virtualenv you created. Then create a new virtualenv with:

virtualenv flask

Then:

cd flask

Then activate the virtualenv:

source bin/activate

Then install  flask:

pip install flask

After that create a file named hello.py:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

Then  run it with:

python hello.py

I hope this helps.

answered May 25, 2022 by narikkadan
• 63,600 points

edited Mar 5

Related Questions In Python

0 votes
1 answer

ImportError: No module named requests

Requests is not available for use by ...READ MORE

answered Jun 26, 2018 in Python by Hamartia's Mask
• 1,580 points
2,663 views
+3 votes
1 answer

Tensorflow 1.5 ImportError: No module named tensorflow.python.client

I think it's a bug in Tensorflow ...READ MORE

answered Sep 25, 2018 in Python by charlie_brown
• 7,720 points
7,129 views
0 votes
1 answer

tensorflow 1.5 ImportError: No module named tensorflow.python.client

Some of the modules have changed in ...READ MORE

answered Oct 5, 2018 in Python by Priyaj
• 58,020 points
2,901 views
0 votes
1 answer

Python error "ImportError: No module named pygame.locals"

You need to download and install the ...READ MORE

answered Jun 18, 2019 in Python by Greg
7,474 views
0 votes
1 answer

Package installed but still says "ImportError: No module named pygame.locals"

you need to do import pygame before ...READ MORE

answered Jul 8, 2021 in Python by Sandro Shtikov

edited Mar 5 4,372 views
0 votes
1 answer

Python: ImportError: No module named Crypto.Cipher

Seems like the pycrypto package is not ...READ MORE

answered Jul 31, 2019 in Python by Hari
25,476 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,679 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP