How to install JPype on OS X Lion for use with Neo4j?

I am trying to use Neo4j for a project and want to interact with it through Python, since I am new to programming and do not know any Java. I follow the instructions but I was stuck with the first step that JPype should install.

I am using OS X 10.7 (lion). I think my configuration is pretty standard with Python 2.7.2 downloaded from the Python website and Java 1.6.0 downloaded from the Apple website.

When i started

% sudo python setup.py install 

In the JPype installer, I get about 100 lines of error code about various .h files, then ends with lines:

 lipo: can't figure out the architecture type of: /var/tmp// ccwOzLi9.out error: command 'gcc-4.2' failed with exit status 1 

I found a gcc error message with JPype , but I followed the instructions there to no avail. I also emailed the author of this publication, and he said that he had never used JPype, worked in OS X 10.6 and had no understanding.

I also emailed the creator of JPype, who told me that he only uses Windows and doesn’t know how to do the installation work on OS X. But if we can solve this, I can tell him the answer and maybe he can add solution to JPype documentation and help many other people!

So, does anyone know what I'm doing wrong? I would like to use Neo4j, but I do not know Java, so I will completely lose how to fix the compiler error.

Based on reading each Google result, my two theory starts are as follows:

  • I somehow use the 32-bit version of Python or Java (although I used the standard official settings and cannot figure out how to switch to 64-bit or if possible)

  • JPype files can only be compiled using GCC 4.0 instead of 4.2. But I can't find anything on the Internet about how to rollback to GCC 4.0 (or if it comes with a 2011 MacBook, and there is some way to get JPype to compile with this).

There is another similar question , but the solution is to use a different adapter that goes through REST instead of connecting directly to Java. I will try if necessary, but I would prefer to use the recommended Neo4j method if possible.

+7
source share
10 answers

I am not a Python guy, but tried installing JPype on my machine:

 % uname -a Darwin fatty-i7.local.tld 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug 9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64 % java -version java version "1.6.0_29" Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527) Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode) 

On OSX Lion, the latest JDK is here:

 /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/JavaVM.framework/ 

A small googling appeared in this post: http://blog.y3xz.com/post/5037243230/installing-jpype-on-mac-os-x

I followed these instructions to modify setup.py and then ran sudo python setup.py install without problems.

Does it help?

+11
source

The "include" directory in the JDK disappeared on my Leo, so JPype could not find jni.h.

I updated setup.py in two places, one to set where to look for jar libraries:

 def setupMacOSX(self): self.javaHome = '/System/Library/Frameworks/JavaVM.framework' self.jdkInclude = "" self.libraries = ["dl"] self.libraryDir = [self.javaHome+"/Home/lib"] self.macros = [('MACOSX',1)] 

And one to set where to find jni.h:

 def setupInclusion(self): self.includeDirs = [ self.javaHome+"/Headers", <other stuff> 
+10
source

For me

 self.javaHome = '/System/Library/Frameworks/JavaVM.framework/Versions/Current/' 

worked.

 $ uname -a Darwin 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr 9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64 $ java -version java version "1.6.0_33" Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720) Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode) 
+4
source

For everyone who is still trying to install Jpype, but in the meantime has updated Mac OS: Andreas Colleger's answer works fine, but with Xcode 4.3 the path changed to /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/JavaVM.framework/Versions/Current/

In ML, this is MacOSX10.8.sdk . At least on my system. :)

+2
source

Here are the instructions I introduced in my README to install JPype on OS X 10.7. Same idea as the answers here, but different enough to guarantee a submission.

The python interface for java (JPype) needs mods for setup.py: In general, you need to make sure that the JPype setup.py script can see your Java “Headers” and “Home” directory I had to install Java from Apple first, so how my default installation of OS X did not turn on with headers on a typical Java installation path, which I found by doing:

 /usr/libexec/java_home 

If you have a Headers directory, you probably won’t need to reinstall Java and you can set the paths to them below based on your Java directory, which is most likely different from those listed in these directions.

After installing Java, I found a new installation in:

 /Library/Java/JavaVirtualMachines/ 

My home directory:

 /Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home/ 

and my header directory:

 /Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Headers/ 

1) The JPype script assumes the headers are in the home directory, but this is not so, so I changed the original var path and created a new var contents path in the setup.py script file - In setupMacOSX(self) :

 self.javaHome = '/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home/' self.javaContents = '/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/' 

2) In setupMacOSX(self) change self.libraryDir :

 self.libraryDir = [self.javaContents + "/Libraries"] 
  • Please note that this step was indicated as needed, but I did not need to do this to make it work, so try without it first.

3) In the setupInclusion parameter, add the paths to the Home / Enable directory and the Headers directory:

 self.javaHome+"/include", self.javaContents + "/Headers", 

4) Starting the installation should now work:

 sudo python setup.py install 
+2
source

I did the same, but choosing

 self.javaHome = '/Developer/SDKs/**MacOSX10.6.sdk**/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/' 

instead

 self.javaHome = '/Developer/SDKs/**MacOSX10.7.sdk**/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/' 

understand that i am using version 6 vs 7 . With version 7, I got the same errors as at the beginning.

+1
source

For me at Mountain Lion

 self.javaHome = '/System/Library/Frameworks/JavaVM.framework/' 

worked.

 $uname -a Darwin 12.0.0 Darwin Kernel Version 12.0.0: Sun Jun 24 23:00:16 PDT 2012; root:xnu-2050.7.9~1/RELEASE_X86_64 x86_64 $ java -version java version "1.6.0_33" Java(TM) SE Runtime Environment (build 1.6.0_33-b03-424-11M3720) Java HotSpot(TM) 64-Bit Server VM (build 20.8-b03-424, mixed mode) 
+1
source

To get Will to respond in a more specific way: I had to change the setupInclusion (self) method, adding the path to the directory that he suggested, i.e. '/System/Library/Frameworks/JavaVM.framework/Headers' on Mountain Lion (version java 1.6). At the same time, the installation of JPype was successful (although it gave a bunch of warnings ...)

0
source

Here is what worked for me - I recommend you put the first line in your profile.

export JAVA_HOME = $ (/ usr / libexec / java_home) cd $ JAVA_HOME sudo ln -s include sudo cp headers include / darwin / * include / cd -

Note that instead of changing setup.py, I am changing the JDK installation. This has the advantage of fixing issues for other projects.

0
source

For those trying to install on Mountain Lion, I had to further edit the setup.py file to include the header files here:

/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers

-one
source

All Articles