2011-06-17 11 views
8

Estoy utilizando la integración de django para neo4j y estoy obteniendo el siguiente rastreo cuando intento crear un nodo.
Tengo instalado JPype y se puede importar.Problema con la creación de un objeto en neo4j

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:
a lo solicitado aquí están mis ajustes 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:
Después de seguir la sugerencia de thobe me sale el siguiente cuando intento importar mis propios 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' 
+0

puede proporcionar su configuración de neo4j en su django settings.py? –

+0

@FelipeCruz: Sí, lo haré hoy –

+0

@ FelipeCruz: Perdón por el retraso. ¿Puede decirme qué podría estar mal aquí? –

Respuesta

1

su settings.py se ve bien ..

¿Tiene el SDK de Java instalado y la variable de entorno JAVA_HOME configurada en su JDK? (Java JRE no es suficiente)

De 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.

+0

Mi JAVA_HOME se configuró correctamente. –

+0

su instancia neo4j se está ejecutando? '$ bin/neo4j start'? –

+0

@FelipeCruz: nope :) –

2

Puede obtener información más detallada acerca de por qué el backend no se pudo encontrar añadiendo esto a NEO4J_OPTIONS:

NEO4J_OPTIONS = { 
    log: True, 
} 

La salida de ese registro facilitará el diagnóstico del problema real y sugerirá una solución.

1

Me encontré con el mismo problema. No importa lo que hice (en Debian), Python no pudo encontrar la variable de entorno JAVA_HOME. La forma más fácil de arreglar, que supongo que sólo puede añadir este en algún lugar de Django, es añadir estas líneas -

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

donde la ruta es la ubicación del JDK que desea utilizar (debe tener la carpeta/bin después con los programas java y javac)

Lo que también probé fue agregar la ubicación a /etc/bash.bashrc. Lo cual no funcionó para mí, pero podría serlo para ti.

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

De todos modos, eso debería comenzar en la dirección correcta. Pero ahora tengo otro problema relacionado en el que estoy atascado sin respuesta durante una semana :(

Cuestiones relacionadas