Problem creating object in neo4j

I use django integration for neo4j and I get the following trace when I try to create a node.
I have JPype installed and 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:
According to my neo4j settings requested here:

 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 executing this sentence, 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' 
+8
django neo4j neo4j.py
source share
3 answers

You can get more details on why the backend could not be found by adding this to NEO4J_OPTIONS:

 NEO4J_OPTIONS = { log: True, } 

The result of this logging will facilitate the diagnosis of an actual problem and propose a fix.

+2
source share

your settings.py look fine ..

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

From Neo4j.py docs:

In some JPype situations, the compilation process may not be associated with the corresponding JNI headers, resulting in compilation errors. First of all, it should be noted that JPype needs JNI headers from the JDK in order to create, this is not enough installed only JRE when building JPype. If the JAVA_HOME environment variable is not set, when building a JPype build script (setup.py) JPype may have problems placing the corresponding JNI headers. If you are building JPype with sudo python setup.py set cannot inherit the JAVA_HOME environment variable in sudo environment, easy warkaround is to run python setup.py bdist before installing.

+1
source share

I ran into the same problem. No matter what I did (on Debian), Python was unable to find the JAVA_HOME environment variable. The easiest way to fix this, which I assume you can simply add to 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 JDK location you want to use (it should have a / bin folder after it with java and javac programs)

I also tried adding the location to / etc / bash.bashrc. Which did not work for me, but could for you.

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

In any case, this should make you start in the right direction. But now I have another related issue for which I got stuck unanswered for a week :(

+1
source share

All Articles