neo4j-graphacademy / app-python

https://graphacademy.neo4j.com/courses/app-python
56 stars 92 forks source link

Error: While importing 'api', an ImportError was raised. #6

Closed G4rb3n closed 1 year ago

G4rb3n commented 2 years ago
image
brandon-haugen commented 2 years ago

I get a slightly different (but I think related) error when trying to run this on macOS.

(neoflix) ➜  app-python git:(fix-readme-activate) ✗ pip install -r requirements.txt
Collecting attrs==21.2.0
  Using cached attrs-21.2.0-py2.py3-none-any.whl (53 kB)
Collecting autopep8==1.6.0
  Using cached autopep8-1.6.0-py2.py3-none-any.whl (45 kB)
Collecting backports.entry-points-selectable==1.1.1
  Using cached backports.entry_points_selectable-1.1.1-py2.py3-none-any.whl (6.2 kB)
Collecting bcrypt==3.2.0
  Using cached bcrypt-3.2.0-cp36-abi3-macosx_10_10_universal2.whl (49 kB)
Collecting certifi==2021.10.8
  Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Collecting cffi==1.15.0
  Using cached cffi-1.15.0-cp310-cp310-macosx_11_0_arm64.whl (173 kB)
Collecting charset-normalizer==2.0.9
  Using cached charset_normalizer-2.0.9-py3-none-any.whl (39 kB)
Collecting click==8.0.3
  Using cached click-8.0.3-py3-none-any.whl (97 kB)
Collecting cryptography==36.0.0
  Using cached cryptography-36.0.0-cp36-abi3-macosx_11_0_arm64.whl (2.5 MB)
Collecting distlib==0.3.3
  Using cached distlib-0.3.3-py2.py3-none-any.whl (496 kB)
Collecting docopt==0.6.2
  Using cached docopt-0.6.2.tar.gz (25 kB)
Collecting filelock==3.4.0
  Using cached filelock-3.4.0-py3-none-any.whl (9.8 kB)
Collecting Flask==2.0.2
  Using cached Flask-2.0.2-py3-none-any.whl (95 kB)
Collecting Flask-JWT==0.3.2
  Using cached Flask-JWT-0.3.2.tar.gz (9.9 kB)
Collecting idna==3.3
  Using cached idna-3.3-py3-none-any.whl (61 kB)
Collecting iniconfig==1.1.1
  Using cached iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting itsdangerous==2.0.1
  Using cached itsdangerous-2.0.1-py3-none-any.whl (18 kB)
Collecting Jinja2==3.0.3
  Using cached Jinja2-3.0.3-py3-none-any.whl (133 kB)
Collecting MarkupSafe==2.0.1
  Using cached MarkupSafe-2.0.1-cp310-cp310-macosx_10_9_universal2.whl (18 kB)
Collecting neo4j==4.4.0
  Using cached neo4j-4.4.0.tar.gz (89 kB)
Collecting packaging==21.3
  Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting pipreqs==0.4.11
  Using cached pipreqs-0.4.11-py2.py3-none-any.whl (32 kB)
Collecting platformdirs==2.4.0
  Using cached platformdirs-2.4.0-py3-none-any.whl (14 kB)
Collecting pluggy==1.0.0
  Using cached pluggy-1.0.0-py2.py3-none-any.whl (13 kB)
Collecting py==1.11.0
  Using cached py-1.11.0-py2.py3-none-any.whl (98 kB)
Collecting pycodestyle==2.8.0
  Using cached pycodestyle-2.8.0-py2.py3-none-any.whl (42 kB)
Collecting pycparser==2.21
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Collecting PyJWT==1.4.2
  Using cached PyJWT-1.4.2-py2.py3-none-any.whl (15 kB)
Collecting pyparsing==3.0.6
  Using cached pyparsing-3.0.6-py3-none-any.whl (97 kB)
Collecting pytest==6.2.5
  Using cached pytest-6.2.5-py3-none-any.whl (280 kB)
Collecting python-dotenv==0.19.2
  Using cached python_dotenv-0.19.2-py2.py3-none-any.whl (17 kB)
Collecting pytz==2021.3
  Using cached pytz-2021.3-py2.py3-none-any.whl (503 kB)
Collecting requests==2.26.0
  Using cached requests-2.26.0-py2.py3-none-any.whl (62 kB)
Collecting six==1.16.0
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting toml==0.10.2
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting urllib3==1.26.7
  Using cached urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
Collecting virtualenv==20.10.0
  Using cached virtualenv-20.10.0-py2.py3-none-any.whl (5.6 MB)
Collecting Werkzeug==2.0.2
  Using cached Werkzeug-2.0.2-py3-none-any.whl (288 kB)
Collecting yarg==0.1.9
  Using cached yarg-0.1.9-py2.py3-none-any.whl (19 kB)
Using legacy 'setup.py install' for docopt, since package 'wheel' is not installed.
Using legacy 'setup.py install' for Flask-JWT, since package 'wheel' is not installed.
Using legacy 'setup.py install' for neo4j, since package 'wheel' is not installed.
Installing collected packages: urllib3, MarkupSafe, idna, charset-normalizer, certifi, Werkzeug, requests, pyparsing, pycparser, Jinja2, itsdangerous, click, yarg, toml, six, pytz, PyJWT, pycodestyle, py, pluggy, platformdirs, packaging, iniconfig, Flask, filelock, docopt, distlib, cffi, backports.entry-points-selectable, attrs, virtualenv, python-dotenv, pytest, pipreqs, neo4j, Flask-JWT, cryptography, bcrypt, autopep8
    Running setup.py install for docopt ... done
    Running setup.py install for neo4j ... done
    Running setup.py install for Flask-JWT ... done
Successfully installed Flask-2.0.2 Flask-JWT-0.3.2 Jinja2-3.0.3 MarkupSafe-2.0.1 PyJWT-1.4.2 Werkzeug-2.0.2 attrs-21.2.0 autopep8-1.6.0 backports.entry-points-selectable-1.1.1 bcrypt-3.2.0 certifi-2021.10.8 cffi-1.15.0 charset-normalizer-2.0.9 click-8.0.3 cryptography-36.0.0 distlib-0.3.3 docopt-0.6.2 filelock-3.4.0 idna-3.3 iniconfig-1.1.1 itsdangerous-2.0.1 neo4j-4.4.0 packaging-21.3 pipreqs-0.4.11 platformdirs-2.4.0 pluggy-1.0.0 py-1.11.0 pycodestyle-2.8.0 pycparser-2.21 pyparsing-3.0.6 pytest-6.2.5 python-dotenv-0.19.2 pytz-2021.3 requests-2.26.0 six-1.16.0 toml-0.10.2 urllib3-1.26.7 virtualenv-20.10.0 yarg-0.1.9
WARNING: You are using pip version 21.2.3; however, version 22.0.4 is available.
You should consider upgrading via the '/Users/brandon/source/neo4j-graph-academy/app-python/neoflix/bin/python -m pip install --upgrade pip' command.
(neoflix) ➜  app-python git:(fix-readme-activate) ✗ flask run
 * Serving Flask app 'api' (lazy loading)
 * Environment: development
 * Debug mode: on
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.

Error: While importing 'api', an ImportError was raised:

Traceback (most recent call last):
  File "/Users/brandon/.pyenv/versions/3.10.0/lib/python3.10/site-packages/flask/cli.py", line 260, in locate_app
    __import__(module_name)
  File "/Users/brandon/source/neo4j-graph-academy/app-python/api/__init__.py", line 7, in <module>
    from flask_jwt import JWT
ModuleNotFoundError: No module named 'flask_jwt'

Uninstalling and reinstalling requirements with pip did not change anything.

adam-cowley commented 2 years ago

Does running pip install flask_jwt fix the error?

brandon-haugen commented 2 years ago

@adam-cowley Unfortunately, no it does not.

adam-cowley commented 2 years ago

Are you using Python version 3.10? I've had another report today about it not working, the project was written with 3.9

brandon-haugen commented 2 years ago

3.10 on an M1 MacBook... maybe the M1 is the problem.

alielbashir commented 2 years ago

I'm getting the same error running Python 3.10.4 on Ubuntu 22.04

alielbashir commented 2 years ago

Downgrading to Python 3.9.12 fixes this for me

maovidal commented 1 year ago

It seems it won't work on 3.10, as Python 3.9 warns:

python3.9/site-packages/jwt/api_jwt.py:5: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
adam-cowley commented 1 year ago

I'm working on a permanent fix for this as I upgrade the Neo4j Driver to 5.0. Stay tuned 👀