Unable to run Python run.py - See error below

(mflix) magics-MBP:mflix-python magic$ python run.py

Traceback (most recent call last):

File “run.py”, line 1, in <module>

from mflix.factory import create_app

File “/Users/magic/m220/mflix-python/mflix/factory.py”, line 3, in <module>

from flask import Flask, render_template

ModuleNotFoundError: No module named ‘flask’

I think you should run that file from the virtual environment you created before

thanks for the reply, I think the issue was I had python alias points to a different location, now, after I changed the python alias to the path in anaconda3 location, I got invalid syntax error now.

magics-MBP:mflix-python magic$ python run.py
Traceback (most recent call last):
File “run.py”, line 1, in
from mflix.factory import create_app
File “/Users/magic/m220/mflix-python/mflix/factory.py”, line 12, in
from mflix.api.movies import movies_api_v1
File “/Users/magic/m220/mflix-python/mflix/api/movies.py”, line 2, in
from mflix.db import get_movie, get_movies, get_movies_by_country,
File “/Users/magic/m220/mflix-python/mflix/db.py”, line 274
except (StopIteration) as _:
^
SyntaxError: invalid syntax

I found this topic and got this invalid syntax issue fixed. :slight_smile:

Fix db.py to be able to start up

What exactly did you do here to fix the error of “No module named ‘flask’”? I keep getting the same error but have no idea how to fix it

@siddharth-paruchuru

Typically this is from the current python executable not being able to find the required library. If you’ve set up your python environment as specified in the README.rst and activated your course environment, run pip install -r requirements to ensure that Flask is installed and available.

Should I run “pip install -r requirements” from the conda environment or from my own machine? Because I have run that command from my own machine and had no luck

Thanks for the help, I never user anaconda before so I am just trying to get used to everything

I was able to get it to work after upgrading pip and re-installing the requirement.txt file

python -m pip install --upgrade pip

pip install -r requirements.txt
1 Like

@siddharth-paruchuru,

Great to hear! Thanks for following up!

Hello Expert,

This is Abhishek Raj, I am getting some error could ypu please help me out ?

Microsoft Windows [Version 6.3.9600]
© 2013 Microsoft Corporation. All rights reserved.

D:\MongoDbPython\mflix-python(1)>pytest -m test_db_connection
ImportError while loading conftest ‘D:\MongoDbPython\mflix-python(1)\tests\conft
est.py’.
tests\conftest.py:2: in
from mflix.factory import create_app
mflix\factory.py:6: in
from flask_bcrypt import Bcrypt
E ModuleNotFoundError: No module named ‘flask_bcrypt’

D:\MongoDbPython\mflix-python(1)>pytest -m test_db_connection
ImportError while loading conftest ‘D:\MongoDbPython\mflix-python(1)\tests\conft
est.py’.
tests\conftest.py:2: in
from mflix.factory import create_app
mflix\factory.py:9: in
from bson import json_util, ObjectId
E ModuleNotFoundError: No module named ‘bson’

D:\MongoDbPython\mflix-python(1)>

Hello Expert,

This is Abhishek Raj, I am not able to established Connection , could you please.
I am sending my issues below please go and suggest me ,

Microsoft Windows [Version 6.3.9600]
© 2013 Microsoft Corporation. All rights reserved.

D:\MongoDbPython\mflix-python(1)>pytest -m test_db_connection
ImportError while loading conftest ‘D:\MongoDbPython\mflix-python(1)\tests\conft
est.py’.
tests\conftest.py:2: in
from mflix.factory import create_app
mflix\factory.py:6: in
from flask_bcrypt import Bcrypt
E ModuleNotFoundError: No module named ‘flask_bcrypt’

D:\MongoDbPython\mflix-python(1)>pytest -m test_db_connection
ImportError while loading conftest ‘D:\MongoDbPython\mflix-python(1)\tests\conft
est.py’.
tests\conftest.py:2: in
from mflix.factory import create_app
mflix\factory.py:9: in
from bson import json_util, ObjectId
E ModuleNotFoundError: No module named ‘bson’

D:\MongoDbPython\mflix-python(1)>pytest -m test_db_connection
============================= test session starts =============================
platform win32 – Python 3.6.5, pytest-4.0.0, py-1.5.3, pluggy-0.8.0
rootdir: D:\MongoDbPython\mflix-python(1), inifile:
plugins: remotedata-0.2.1, openfiles-0.3.0, flask-0.14.0, doctestplus-0.1.3, arr
aydiff-0.2
collected 39 items / 1 errors / 39 deselected

=================================== ERRORS ====================================
________________ ERROR collecting tests/test_db_connection.py _________________
c:\users\araj\appdata\local\continuum\anaconda3\lib\site-packages_pytest\python
.py:450: in _importtestmodule
mod = self.fspath.pyimport(ensuresyspath=importmode)
c:\users\araj\appdata\local\continuum\anaconda3\lib\site-packages\py_path\local
.py:668: in pyimport
import(modname)
E File “D:\MongoDbPython\mflix-python(1)\tests\test_db_connection.py”, line
17
E db = MongoClient(config['mongodb+srv://m220student:@mflix-
q0fyq.mongodb.net/test?retryWrites=true
E
^
E SyntaxError: EOL while scanning string literal
!!! Interrupted: 1 errors during collection !!!
=================== 39 deselected, 1 error in 0.81 seconds ====================

D:\MongoDbPython\mflix-python(1)>

Thankyou