cancel
Showing results for 
Search instead for 
Did you mean: 

Flask issues with "Building applications with Python" course

flask run executes successfully, but when I go to localhost:3000, I get 

flask.cli.NoAppException

flask.cli.NoAppException: While importing "api", an ImportError was raised: Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 240, in locate_app __import__(module_name) File "/Users/irene221b/Documents/GitHub/app-python/api/__init__.py", line 7, in <module> from flask_jwt import JWT ModuleNotFoundError: No module named 'flask_jwt'

It installed successfully with all the requirements:

pip install flask_jwt          

Requirement already satisfied: flask_jwt in /Users/irene221b/sandbox/lib/python3.9/site-packages (0.3.2)

Requirement already satisfied: Flask>=0.9 in /Users/irene221b/sandbox/lib/python3.9/site-packages (from flask_jwt) (2.0.2)

Requirement already satisfied: PyJWT<1.5.0,>=1.4.0 in /Users/irene221b/sandbox/lib/python3.9/site-packages (from flask_jwt) (1.4.2)

Requirement already satisfied: Werkzeug>=2.0 in /Users/irene221b/sandbox/lib/python3.9/site-packages (from Flask>=0.9->flask_jwt) (2.0.2)

Requirement already satisfied: itsdangerous>=2.0 in /Users/irene221b/sandbox/lib/python3.9/site-packages (from Flask>=0.9->flask_jwt) (2.0.1)

Requirement already satisfied: click>=7.1.2 in /Users/irene221b/sandbox/lib/python3.9/site-packages (from Flask>=0.9->flask_jwt) (8.0.3)

Requirement already satisfied: Jinja2>=3.0 in /Users/irene221b/sandbox/lib/python3.9/site-packages (from Flask>=0.9->flask_jwt) (3.0.3)

Requirement already satisfied: MarkupSafe>=2.0 in /Users/irene221b/sandbox/lib/python3.9/site-packages (from Jinja2>=3.0->Flask>=0.9->flask_jwt) (2.0.1)
4 REPLIES 4

adam_cowley
Neo4j
Neo4j

Hi Irene,

Can you trying `PYTHONPATH=. flask run`  and let me know if that fixes the issue? 

No, it didn't, sorry.

rouven_bauer
Neo4j
Neo4j

👋 what does pip --version report? This might be a long shot but maybe you're using pip that belongs to Python 2 or another Python version than the one used to run the flask app.

Actually, looking closer at your stack traces (🙌 thanks for providing them), it looks like this is the case.
File "/usr/local/lib/python3.9/site-packages/flask/cli.py", line 240, in locate_app looks like flask is run from the global Python interpreter, while Requirement already satisfied: flask_jwt in /Users/irene221b/sandbox/lib/python3.9/site-packages (0.3.2) suggests that pip is run within the sandbox (virtualenv, I guess?).

So try to start the app with python -m flask ... instead of flask ...

I have just upgraded the entire repo to use the 5.0 version of the Python Driver and at the same time replaced the flask_jwt extension with another library and also fixed some outstanding CORS issues. You should be good now but feel free to ping me if you continue to have problems.