close

[Solved] ImportError: No module named flask

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 ?

  1. 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.

  2. 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

Please Rate Our Solution to Motivate Us For Give Our Best

1 thought on “[Solved] ImportError: No module named flask”

Leave a Comment