python flask import error

Solution 1:

I ran into this error because I named the test file as flask.py and tried to run it! It creates namespace conflict with the real flask module!

Delete the local test file that you named flask.py and the respective flask.pyc. Give some other name! This will happen with other modules like socket etc where you are likely to give the same name for the test file as the standard module :-)

Solution 2:

The reason is your python file name is flask.

Solution 3:

Just run apt-get install python3-flask

Edited to install the python3 version, since nobody should be using python2 now.

Solution 4:

Just rename flask.py file also delete flask.pyc file