I am getting nomodule flask error

I have installed flask successfully using the below command on windows environment
pip install flask
i executed also below command
pip install -r requirements.txt

but still i am getting below issue

Traceback (most recent call last):
File “run.py”, line 1, in
from mflix.factory import create_app
File “C:\Users\abc\Downloads\mflix-python\mflix\factory.py”, line 4, in
from flask import Flask, render_template
ModuleNotFoundError: No module named ‘flask’

if you use pycharm , install all requirements and then check if you have changed the uri in .ini file.
i think the .ini file changes are the key if you have installed the modules.

Hi @rajesh_50804,

Please try after reinstalling flask module and also make sure that PATH variable is set up for the same.

If it still does not resolve the issue, please share the output when you run python install -r requirements.txt.

Kanika

Thnaks, Issue is resolved. But when i am going to mflix validation what will b my user name or password. m220student and m220password or anything fine.

If you help on it it would be great for me.

Thanks in advance:slightly_smiling_face:

Thanks, I am able to import flask now.
:slightly_smiling_face:

Kanika, I have tried but unable to resolve this issue.
Here is the output of my installation, I don’t understand whats wrong with my code

(mflix) C:\Users\raigu\Downloads\mflix-python>pip install -r requirements.txt
Requirement already satisfied: Flask==0.12.4 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 1)) (0.12.4)
Requirement already satisfied: Flask-Bcrypt==0.7.1 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 2)) (0.7.1)
Requirement already satisfied: Flask-Login==0.4.0 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 3)) (0.4.0)
Requirement already satisfied: pymongo==3.7.0 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 4)) (3.7.0)
Requirement already satisfied: dnspython==1.15.0 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 5)) (1.15.0)
Requirement already satisfied: pytest==3.3.0 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 6)) (3.3.0)
Requirement already satisfied: pytest-flask==0.10.0 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 7)) (0.10.0)
Requirement already satisfied: Flask-Cors==3.0.3 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 8)) (3.0.3)
Requirement already satisfied: flask-jwt-extended==3.7.0 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 9)) (3.7.0)
Requirement already satisfied: faker==0.8.13 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 10)) (0.8.13)
Requirement already satisfied: jupyter==1.0.0 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 11)) (1.0.0)
Requirement already satisfied: jupyter-client==5.2.4 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 12)) (5.2.4)
Requirement already satisfied: jupyter-console==6.0.0 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 13)) (6.0.0)
Requirement already satisfied: jupyter-core==4.4.0 in c:\users\raigu\anaconda3\lib\site-packages (from -r requirements.txt (line 14)) (4.4.0)
Requirement already satisfied: itsdangerous>=0.21 in c:\users\raigu\anaconda3\lib\site-packages (from Flask==0.12.4->-r requirements.txt (line 1)) (1.1.0)
Requirement already satisfied: Werkzeug>=0.7 in c:\users\raigu\anaconda3\lib\site-packages (from Flask==0.12.4->-r requirements.txt (line 1)) (0.14.1)
Requirement already satisfied: click>=2.0 in c:\users\raigu\anaconda3\lib\site-packages (from Flask==0.12.4->-r requirements.txt (line 1)) (7.0)
Requirement already satisfied: Jinja2>=2.4 in c:\users\raigu\anaconda3\lib\site-packages (from Flask==0.12.4->-r requirements.txt (line 1)) (2.10)
Requirement already satisfied: bcrypt in c:\users\raigu\anaconda3\lib\site-packages (from Flask-Bcrypt==0.7.1->-r requirements.txt (line 2)) (3.1.7)
Requirement already satisfied: colorama; sys_platform == “win32” in c:\users\raigu\anaconda3\lib\site-packages (from pytest==3.3.0->-r requirements.txt (line 6)) (0.4.1)
Requirement already satisfied: py>=1.5.0 in c:\users\raigu\anaconda3\lib\site-packages (from pytest==3.3.0->-r requirements.txt (line 6)) (1.8.0)
Requirement already satisfied: pluggy<0.7,>=0.5 in c:\users\raigu\anaconda3\lib\site-packages (from pytest==3.3.0->-r requirements.txt (line 6)) (0.6.0)
Requirement already satisfied: six>=1.10.0 in c:\users\raigu\anaconda3\lib\site-packages (from pytest==3.3.0->-r requirements.txt (line 6)) (1.12.0)
Requirement already satisfied: attrs>=17.2.0 in c:\users\raigu\anaconda3\lib\site-packages (from pytest==3.3.0->-r requirements.txt (line 6)) (19.1.0)
Requirement already satisfied: setuptools in c:\users\raigu\anaconda3\lib\site-packages (from pytest==3.3.0->-r requirements.txt (line 6)) (40.8.0)
Requirement already satisfied: PyJWT in c:\users\raigu\anaconda3\lib\site-packages (from flask-jwt-extended==3.7.0->-r requirements.txt (line 9)) (1.7.1)
Requirement already satisfied: python-dateutil>=2.4 in c:\users\raigu\anaconda3\lib\site-packages (from faker==0.8.13->-r requirements.txt (line 10)) (2.8.0)
Requirement already satisfied: text-unidecode==1.2 in c:\users\raigu\anaconda3\lib\site-packages (from faker==0.8.13->-r requirements.txt (line 10)) (1.2)
Requirement already satisfied: ipywidgets in c:\users\raigu\anaconda3\lib\site-packages (from jupyter==1.0.0->-r requirements.txt (line 11)) (7.4.2)
Requirement already satisfied: notebook in c:\users\raigu\anaconda3\lib\site-packages (from jupyter==1.0.0->-r requirements.txt (line 11)) (5.7.8)
Requirement already satisfied: qtconsole in c:\users\raigu\anaconda3\lib\site-packages (from jupyter==1.0.0->-r requirements.txt (line 11)) (4.4.3)
Requirement already satisfied: nbconvert in c:\users\raigu\anaconda3\lib\site-packages (from jupyter==1.0.0->-r requirements.txt (line 11)) (5.4.1)
Requirement already satisfied: ipykernel in c:\users\raigu\anaconda3\lib\site-packages (from jupyter==1.0.0->-r requirements.txt (line 11)) (5.1.0)
Requirement already satisfied: pyzmq>=13 in c:\users\raigu\anaconda3\lib\site-packages (from jupyter-client==5.2.4->-r requirements.txt (line 12)) (18.0.0)
Requirement already satisfied: tornado>=4.1 in c:\users\raigu\anaconda3\lib\site-packages (from jupyter-client==5.2.4->-r requirements.txt (line 12)) (6.0.2)
Requirement already satisfied: traitlets in c:\users\raigu\anaconda3\lib\site-packages (from jupyter-client==5.2.4->-r requirements.txt (line 12)) (4.3.2)
Requirement already satisfied: ipython in c:\users\raigu\anaconda3\lib\site-packages (from jupyter-console==6.0.0->-r requirements.txt (line 13)) (7.4.0)
Requirement already satisfied: prompt_toolkit<2.1.0,>=2.0.0 in c:\users\raigu\anaconda3\lib\site-packages (from jupyter-console==6.0.0->-r requirements.txt (line 13)) (2.0.9)
Requirement already satisfied: pygments in c:\users\raigu\anaconda3\lib\site-packages (from jupyter-console==6.0.0->-r requirements.txt (line 13)) (2.3.1)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\raigu\anaconda3\lib\site-packages (from Jinja2>=2.4->Flask==0.12.4->-r requirements.txt (line 1)) (1.1.1)
Requirement already satisfied: cffi>=1.1 in c:\users\raigu\anaconda3\lib\site-packages (from bcrypt->Flask-Bcrypt==0.7.1->-r requirements.txt (line 2)) (1.12.2)
Requirement already satisfied: widgetsnbextension~=3.4.0 in c:\users\raigu\anaconda3\lib\site-packages (from ipywidgets->jupyter==1.0.0->-r requirements.txt (line 11)) (3.4.2)
Requirement already satisfied: nbformat>=4.2.0 in c:\users\raigu\anaconda3\lib\site-packages (from ipywidgets->jupyter==1.0.0->-r requirements.txt (line 11)) (4.4.0)
Requirement already satisfied: Send2Trash in c:\users\raigu\anaconda3\lib\site-packages (from notebook->jupyter==1.0.0->-r requirements.txt (line 11)) (1.5.0)
Requirement already satisfied: terminado>=0.8.1 in c:\users\raigu\anaconda3\lib\site-packages (from notebook->jupyter==1.0.0->-r requirements.txt (line 11)) (0.8.1)
Requirement already satisfied: prometheus-client in c:\users\raigu\anaconda3\lib\site-packages (from notebook->jupyter==1.0.0->-r requirements.txt (line 11)) (0.6.0)
Requirement already satisfied: ipython-genutils in c:\users\raigu\anaconda3\lib\site-packages (from notebook->jupyter==1.0.0->-r requirements.txt (line 11)) (0.2.0)
Requirement already satisfied: mistune>=0.8.1 in c:\users\raigu\anaconda3\lib\site-packages (from nbconvert->jupyter==1.0.0->-r requirements.txt (line 11)) (0.8.4)
Requirement already satisfied: entrypoints>=0.2.2 in c:\users\raigu\anaconda3\lib\site-packages (from nbconvert->jupyter==1.0.0->-r requirements.txt (line 11)) (0.3)
Requirement already satisfied: bleach in c:\users\raigu\anaconda3\lib\site-packages (from nbconvert->jupyter==1.0.0->-r requirements.txt (line 11)) (3.1.0)
Requirement already satisfied: pandocfilters>=1.4.1 in c:\users\raigu\anaconda3\lib\site-packages (from nbconvert->jupyter==1.0.0->-r requirements.txt (line 11)) (1.4.2)
Requirement already satisfied: testpath in c:\users\raigu\anaconda3\lib\site-packages (from nbconvert->jupyter==1.0.0->-r requirements.txt (line 11)) (0.4.2)
Requirement already satisfied: defusedxml in c:\users\raigu\anaconda3\lib\site-packages (from nbconvert->jupyter==1.0.0->-r requirements.txt (line 11)) (0.5.0)
Requirement already satisfied: decorator in c:\users\raigu\anaconda3\lib\site-packages (from traitlets->jupyter-client==5.2.4->-r requirements.txt (line 12)) (4.4.0)
Requirement already satisfied: pickleshare in c:\users\raigu\anaconda3\lib\site-packages (from ipython->jupyter-console==6.0.0->-r requirements.txt (line 13)) (0.7.5)
Requirement already satisfied: backcall in c:\users\raigu\anaconda3\lib\site-packages (from ipython->jupyter-console==6.0.0->-r requirements.txt (line 13)) (0.1.0)
Requirement already satisfied: jedi>=0.10 in c:\users\raigu\anaconda3\lib\site-packages (from ipython->jupyter-console==6.0.0->-r requirements.txt (line 13)) (0.13.3)
Requirement already satisfied: wcwidth in c:\users\raigu\anaconda3\lib\site-packages (from prompt_toolkit<2.1.0,>=2.0.0->jupyter-console==6.0.0->-r requirements.txt (line 13)) (0.1.7)
Requirement already satisfied: pycparser in c:\users\raigu\anaconda3\lib\site-packages (from cffi>=1.1->bcrypt->Flask-Bcrypt==0.7.1->-r requirements.txt (line 2)) (2.19)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in c:\users\raigu\anaconda3\lib\site-packages (from nbformat>=4.2.0->ipywidgets->jupyter==1.0.0->-r requirements.txt (line 11)) (3.0.1)
Requirement already satisfied: webencodings in c:\users\raigu\anaconda3\lib\site-packages (from bleach->nbconvert->jupyter==1.0.0->-r requirements.txt (line 11)) (0.5.1)
Requirement already satisfied: parso>=0.3.0 in c:\users\raigu\anaconda3\lib\site-packages (from jedi>=0.10->ipython->jupyter-console==6.0.0->-r requirements.txt (line 13)) (0.3.4)
Requirement already satisfied: pyrsistent>=0.14.0 in c:\users\raigu\anaconda3\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets->jupyter==1.0.0->-r requirements.txt (line 11)) (0.14.11)

(mflix) C:\Users\raigu\Downloads\mflix-python>python run.py
Traceback (most recent call last):
File “run.py”, line 1, in
from mflix.factory import create_app
File “C:\Users\raigu\Downloads\mflix-python\mflix\factory.py”, line 3, in
from flask import Flask, render_template
ModuleNotFoundError: No module named ‘flask’

For cluster used in this course, we need to have this username/password only:

username: m220student
password: m220password

Kanika

Hi @gulshanr,

Make sure your virtual environment or conda environment is active.

Also, there are few suggestions which worked for other students who encountered the same issue:

Reinstalling Flask and updating the PATH variable worked.

Let me know if this helps.

Kanika

Finally I found reason, I had multiple flavor of Python, uninstall all except Anaconda and it worked

Thats great @gulshanr. :slight_smile:

Kanika

how did you found and uninstalled different flavor of python, could you please let me know, im too facing same issue

What version is showing when you run python --version ?

Kanika

Hi Kanika,

When I activate Conda by running “conda activate mflix” and it shows My python version is 2.7.
but without activating conda it shows my version to be 3.7.4

Issue Solved
I ran the command “python3 run.py” instead of “python run.py”