Problema com a criação de um objeto em Neo4j

votos
8

Eu estou usando a integração Django para Neo4j e estou recebendo o seguinte traceback quando eu estou tentando criar um nó.
Eu tenho JPype instalado e pode ser importado.

 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:
Conforme solicitado, aqui estão as minhas configurações 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.
}

EDIT:
Depois de seguir a sugestão de thobe recebo a seguinte quando tento importar meus próprios modelos:

    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'
Publicado 17/06/2011 em 10:49
fonte usuário
Em outras línguas...                            


3 respostas

votos
2

Você pode obter informações mais detalhada sobre por que o backend não pôde ser encontrado adicionando este para NEO4J_OPTIONS:

NEO4J_OPTIONS = {
    log: True,
}

A saída do que a exploração madeireira irá torná-lo mais fácil de diagnosticar o problema real e sugerir uma correção.

Respondeu 27/06/2011 em 13:43
fonte usuário

votos
1

Eu tive o mesmo problema. Não importa o que eu fiz (na Debian) Python não poderia encontrar a variável de ambiente JAVA_HOME. A maneira mais fácil de corrigi-lo, o que eu presumo que você pode apenas adicionar isso em algum lugar no Django, é adicionar estas linhas -

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

onde o caminho é a localização do JDK que você deseja usar (ele deve ter pasta / bin-se depois com programas java e javac)

O que eu também tentei foi adicionar o local à /etc/bash.bashrc. Que não funcionou para mim, mas poder para você.

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

De qualquer forma, que deve começar na direção certa. Mas agora eu tenho um outro problema relacionado Eu estou preso em sem resposta para uma semana agora :(

Respondeu 27/07/2011 em 07:11
fonte usuário

votos
1

seu settings.py parece ok ..

Você tem java SDK instalado e variável de ambiente JAVA_HOME definido para o seu JDK? (Java JRE não é suficiente)

De docs Neo4j.py:

Em algumas situações, o processo de compilação JPype pode não conectar com os cabeçalhos JNI adequados, resultando em erros de compilação. A primeira coisa a notar é que JPype precisa dos cabeçalhos JNI de um JDK, a fim de construir, não basta ter apenas um JRE instalado na construção JPype. Se a variável de ambiente JAVA_HOME não está definido quando a construção JPype o script de construção (setup.py) de JPype pode ter problemas para localizar os cabeçalhos JNI apropriadas. Se você está construindo JPype com python sudo setup.py install você não pode herdar a variável de ambiente JAVA_HOME para o ambiente sudo, um warkaround fácil é executar python setup.py bdist antes de instalar.

Respondeu 22/06/2011 em 21:13
fonte usuário

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more