我正在尝试将一个图库连接到一个项目tiangolo/全栈fastapi postgresql。但每次我遇到导入错误时。请告诉我,也许有人面临类似的问题。后端启动日志:
Checking for script in /app/prestart.sh
Running script /app/prestart.sh
INFO:__main__:Initializing service
INFO:__main__:Starting call to '__main__.init', this is the 1st time calling it.
INFO:__main__:Service finished initializing
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
Traceback (most recent call last):
File "/app/app/initial_data.py", line 1, in <module>
from app.dbase.init_db import init_db
File "/app/app/dbase/init_db.py", line 14, in <module>
from neomodel import db as neodb
File "/usr/local/lib/python3.7/site-packages/neomodel/__init__.py", line 3, in <module>
from .core import *
File "/usr/local/lib/python3.7/site-packages/neomodel/core.py", line 9, in <module>
from neomodel.util import Database, classproperty, _UnsavedNode, _get_node_properties
File "/usr/local/lib/python3.7/site-packages/neomodel/util.py", line 8, in <module>
from neo4j.v1 import GraphDatabase, basic_auth, CypherError, SessionError
ImportError: cannot import name 'CypherError' from 'neo4j.v1' (/usr/local/lib/python3.7/site-packages/neo4j/v1/__init__.py)
我被呼叫的代码:
import logging
from sqlalchemy.orm import Session
from app import crud, schemas
from app.core.config import settings
from app.dbase import base
from neomodel import db as neodb
from neomodel import config, install_all_labels
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def init_db(dbase: Session) -> None:
user = crud.user.get_by_email(dbase, email=settings.FIRST_SUPERUSER)
if not user:
user_in = schemas.UserCreate(
email=settings.FIRST_SUPERUSER,
password=settings.FIRST_SUPERUSER_PASSWORD,
is_superuser=True,
)
user = crud.user.create(dbase, obj_in=user_in)
neodb.set_connection("bolt://neo4j:password@neo4j:7687")
person = Profile(email=settings.FIRST_SUPERUSER)
person.save()
country = Country(name="Russia")
country.save()
person.country.connect(country)
neomodel的要求表明它需要neo4j 3.0、3.1、3.2或3.3
请参阅文档:https://neomodel.readthedocs.io/en/latest/#requirements