在neo4j中创建对象的问题

发布于 2024-11-16 04:24:34 字数 12095 浏览 3 评论 0原文

我正在使用 neo4j 的 django 集成,当我尝试创建节点时,我收到以下回溯。
我确实安装了 JPype 并且可以导入它。

 p = Person.objects.create(first_name='omer', last_name='katz')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 138, in create
    return self.get_query_set().create(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/model/django_model/__init__.py", line 362, in create
    obj.save(force_insert=True)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 460, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_util.py", line 47, in __get__
    method, graphdb = self.descr_get(obj, cls)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_util.py", line 41, in descr_get
    graphdb = self.accessor.__get__(obj, cls)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/model/django_model/__init__.py", line 58, in __get__
    return DjangoNeo.neo
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/model/django_model/__init__.py", line 124, in neo
    return self.__setup_neo()
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/model/django_model/__init__.py", line 136, in __setup_neo
    self.__neo = NeoService(resource_uri, **options)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/__init__.py", line 522, in __new__
    neo = core.load_neo(resource_uri, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_core.py", line 180, in load_neo
    backend.initialize(**parameters)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 61, in initialize
    raise ImportError("No applicable backend found.")
ImportError: No applicable backend found.

编辑:
按照这里的要求是我的 neo4j 设置:

NEO4J_RESOURCE_URI = '/var/neo4j/neo4django'
# NEO4J_RESOURCE_URI should be the path to where
#    you want to store the Neo4j database.

NEO4J_OPTIONS = {
    # this is optional and can be used to specify
    # extra startup parameters for Neo4j, such as
    # the classpath to load Neo4j from.
}

编辑:
遵循 thobe 的建议后,当我尝试导入自己的模型时,我得到以下信息:

    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      FERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

ile "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
    embedded, remote = implementation.initialize(classpath, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
    jvm = jpype.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
    return _linux.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
    jvm = _getJVMFromJavaHome()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
    if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
ERROR:root:Importing native backends failed.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
    embedded, remote = implementation.initialize(classpath, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
    jvm = jpype.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
    return _linux.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
    jvm = _getJVMFromJavaHome()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
    if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
ERROR:root:Importing native backends failed.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
    embedded, remote = implementation.initialize(classpath, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
    jvm = jpype.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
    return _linux.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
    jvm = _getJVMFromJavaHome()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
    if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
ERROR:root:Importing native backends failed.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
    embedded, remote = implementation.initialize(classpath, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
    jvm = jpype.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
    return _linux.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
    jvm = _getJVMFromJavaHome()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
    if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

I am using the django integration for neo4j and I'm getting the following traceback when I'm trying to create a node.
I do have JPype installed and it can be imported.

 p = Person.objects.create(first_name='omer', last_name='katz')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 138, in create
    return self.get_query_set().create(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/model/django_model/__init__.py", line 362, in create
    obj.save(force_insert=True)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 460, in save
    self.save_base(using=using, force_insert=force_insert, force_update=force_update)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_util.py", line 47, in __get__
    method, graphdb = self.descr_get(obj, cls)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_util.py", line 41, in descr_get
    graphdb = self.accessor.__get__(obj, cls)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/model/django_model/__init__.py", line 58, in __get__
    return DjangoNeo.neo
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/model/django_model/__init__.py", line 124, in neo
    return self.__setup_neo()
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/model/django_model/__init__.py", line 136, in __setup_neo
    self.__neo = NeoService(resource_uri, **options)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/__init__.py", line 522, in __new__
    neo = core.load_neo(resource_uri, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_core.py", line 180, in load_neo
    backend.initialize(**parameters)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 61, in initialize
    raise ImportError("No applicable backend found.")
ImportError: No applicable backend found.

EDIT:
As requested here are my neo4j settings:

NEO4J_RESOURCE_URI = '/var/neo4j/neo4django'
# NEO4J_RESOURCE_URI should be the path to where
#    you want to store the Neo4j database.

NEO4J_OPTIONS = {
    # this is optional and can be used to specify
    # extra startup parameters for Neo4j, such as
    # the classpath to load Neo4j from.
}

EDIT:
After following thobe's suggestion I get the following when I try to import my own models:

    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      FERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
    ERROR:root:Importing native backends failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
        embedded, remote = implementation.initialize(classpath, params)
      File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
        jvm = jpype.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
        return _linux.getDefaultJVMPath()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
        jvm = _getJVMFromJavaHome()
      File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
        if os.path.exists(java_home+"/bin/javac") :
    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

ile "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
    embedded, remote = implementation.initialize(classpath, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
    jvm = jpype.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
    return _linux.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
    jvm = _getJVMFromJavaHome()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
    if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
ERROR:root:Importing native backends failed.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
    embedded, remote = implementation.initialize(classpath, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
    jvm = jpype.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
    return _linux.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
    jvm = _getJVMFromJavaHome()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
    if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
ERROR:root:Importing native backends failed.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
    embedded, remote = implementation.initialize(classpath, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
    jvm = jpype.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
    return _linux.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
    jvm = _getJVMFromJavaHome()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
    if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
ERROR:root:Importing native backends failed.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/__init__.py", line 51, in initialize
    embedded, remote = implementation.initialize(classpath, params)
  File "/usr/local/lib/python2.7/dist-packages/Neo4j.py-0.1_SNAPSHOT-py2.7.egg/neo4j/_backend/reflection.py", line 44, in initialize
    jvm = jpype.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_core.py", line 96, in getDefaultJVMPath
    return _linux.getDefaultJVMPath()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 36, in getDefaultJVMPath
    jvm = _getJVMFromJavaHome()
  File "/usr/local/lib/python2.7/dist-packages/jpype/_linux.py", line 55, in _getJVMFromJavaHome
    if os.path.exists(java_home+"/bin/javac") :
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酷炫老祖宗 2024-11-23 04:24:34

您可以通过将其添加到 NEO4J_OPTIONS 来获取有关为何找不到后端的更详细信息:

NEO4J_OPTIONS = {
    log: True,
}

该日志记录的输出将使诊断实际问题并提出修复建议变得更加容易。

You can get more verbose information about why the backend couldn't be found by adding this to NEO4J_OPTIONS:

NEO4J_OPTIONS = {
    log: True,
}

The output from that logging will make it easier to diagnose the actual issue and suggest a fix.

避讳 2024-11-23 04:24:34

你的settings.py看起来没问题。

你是否安装了java SDK并将JAVA_HOME环境变量设置为你的JDK? (java JRE 是不够的)

来自 Neo4j.py 文档:

在某些情况下,JPype
编译过程可能无法链接
使用适当的 JNI 标头,
导致编译错误。这
首先要注意的是 JPype
需要 JDK 中的 JNI 标头
为了建造,仅仅
仅在以下情况下安装 JRE
构建 JPype。如果JAVA_HOME
环境变量未设置时
构建 JPype 构建脚本
JPype 的 (setup.py) 可能有
定位适当的 JNI 时出现问题
标头。如果您正在构建 JPype
使用 sudo python setup.py 安装你
可能不会继承JAVA_HOME
环境变量进入sudo
环境,一个简单的解决方法是
之前运行 python setup.py bdist
安装。

your settings.py looks ok..

Do you have java SDK installed and JAVA_HOME environment variable set to your JDK? (java JRE is not enough)

From Neo4j.py docs:

In some situations the JPype
compilation process might not link
with the appropriate JNI headers,
resulting in compilation errors. The
first thing to note is that JPype
needs the JNI headers from a JDK in
order to build, it is not enough to
only have a JRE installed when
building JPype. If the JAVA_HOME
environment variable is not set when
building JPype the build script
(setup.py) of JPype might have
problems locating the appropriate JNI
headers. If you are building JPype
with sudo python setup.py install you
might not inherit the JAVA_HOME
environment variable into the sudo
environment, an easy warkaround is to
run python setup.py bdist before
install.

强辩 2024-11-23 04:24:34

我遇到了同样的问题。无论我做什么(在 Debian 上),Python 都找不到 JAVA_HOME 环境变量。修复它的最简单方法(我认为您可以在 Django 中的某个位置添加它)是添加这些行 -

java_home = os.getenv("JAVA_HOME")
if(java_home == None):
    os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-6-openjdk"

其中路径是您要使用的 JDK 的位置(它后面应该有文件夹 /bin 和 java ) javac 程序)

我还尝试将位置添加到 /etc/bash.bashrc 中。这对我不起作用,但可能对你有用。

JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH

不管怎样,这应该让你朝着正确的方向开始。但现在我有另一个相关的问题,我已经一周没有答案了:(

I ran into the same problem. No matter what I did (on Debian) Python couldn't find the JAVA_HOME environmental variable. The easiest way to fix it, which I presume you can just add this somewhere in Django, is to add these lines -

java_home = os.getenv("JAVA_HOME")
if(java_home == None):
    os.environ["JAVA_HOME"] = "/usr/lib/jvm/java-6-openjdk"

where the path is the location of the JDK you want to use (it should have folder /bin after it with java and javac programs)

What I also tried was add the location to /etc/bash.bashrc. Which didn't work for me but might for you.

JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH

Anyway, that should get you started in the right direction. But now I have another related problem I'm stuck on with no answer for a week now :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文