Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to import Flask But I am facing following error ImportError: No module named flask in python. So Here I am Explain to you all the possible solutions here.
Without wasting your time, Let’s start This Article to Solve This Error.
How ImportError: No module named flask Error Occurs ?
I am trying to import Flask But I am facing following error.
Traceback (most recent call last):
File "./my_program.py", line 3, in <module>
from app import app
File "/Users/ssc/Desktop/Project_program/app/__init__.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
How To Solve ImportError: No module named flask Error ?
- How To Solve ImportError: No module named flask Error ?
To Solve ImportError: No module named flask Error If You are using python 3.X version then all you need to do is just install flas module with this command: pip3 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. - ImportError: No module named flask
To Solve ImportError: No module named flask Error If You are using python 3.X version then all you need to do is just install flas module with this command: pip3 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.
Solution 1: For python 3.X
If You are using python 3.X version then all you need to do is just install flas module with this command.
pip3 install flask
Solution 2: Working with environment
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
Then create a file named helloWorld.py
and add below code in file.
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
and run it with:
python helloWorld.py
Summary
It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?
Also, Read
Thanks you, Solution 2 worked for me!!
thanks a lot ! solution 1 recommended by you worked
thanks its works!!!
pip install flask
My pleasure to help You pythonlearner and Thank You For your Valuable Word!
If use Python3 use apt-get install libapache2-mod-wsgi-py3