cancel
Showing results for 
Search instead for 
Did you mean: 

Building Neo4j Applications with Python - Workaround for Python version 3.10 ?

stephflint
Node Clone

Hi, I'm trying to do the Building Neo4j Applications with Python developer tutorial and getting stuck with the setup. Specifically with running Flask. When I ran it the first time I didn't have Flask_JWT installed and had to do that manually - using pip3 install Flask-JWT. Now when I try to "run flask" I get the following error:

 

 

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

Traceback (most recent call last):
  File "/Users/dan/code/neo4j/neo4j_app_python/sandbox/lib/python3.10/site-packages/flask/cli.py", line 218, in locate_app
    __import__(module_name)
  File "/Users/dan/code/neo4j/neo4j_app_python/app-python/api/__init__.py", line 7, in <module>
    from flask_jwt import JWT
  File "/Users/dan/code/neo4j/neo4j_app_python/sandbox/lib/python3.10/site-packages/flask_jwt/__init__.py", line 16, in <module>
    import jwt
  File "/Users/dan/code/neo4j/neo4j_app_python/sandbox/lib/python3.10/site-packages/jwt/__init__.py", line 19, in <module>
    from .api_jwt import (
  File "/Users/dan/code/neo4j/neo4j_app_python/sandbox/lib/python3.10/site-packages/jwt/api_jwt.py", line 5, in <module>
    from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/Users/dan/.pyenv/versions/3.10.6/lib/python3.10/collections/__init__.py)

 

 

The tutorial is made for using Python 3.9.9 and I'm using 3.10.6 - from looking at similar community questions I understand this to be the problem. Is it completely necessary to downgrade? Or is there a workaround?

I would like to apply Python/Neo4j compatibility for apps and would prefer not to have to use Python v 3.9 in that case

Thanks in advance

1 REPLY 1

adam_cowley
Neo4j
Neo4j

I have just updated the entire repo to use the 5.0 version of the Python Driver which also replaces this dependency.  Let me know if that works for you 🤞