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

后端 未结 10 1533
梦谈多话
梦谈多话 2020-12-06 12:51

I am trying to use Neo4j for a project, and want to interface with it through Python since I\'m a newbie to programming and don\'t know any Java. I\'m following the installa

10条回答
  •  一个人的身影
    2020-12-06 13:30

    Here are directions I put in my README to install JPype on OS X 10.7. Same idea as the answers here but different enough to warrant the submission.

    The python interface to java (JPype) needs mods to the setup.py: In summary, you need to make sure the JPype setup.py script can see your Java SDK "Headers" and "Home" directory I had to install Java from Apple first since my default OS X installation did not come with Headers in the typical Java install path which I found by executing:

    /usr/libexec/java_home
    

    If you do happen to have a Headers dir, you probably do not need to reinstall Java and can set the path vars below based on your java HOME directory which is likely different from those in these directions

    After I installed Java, I found the new installation in:

    /Library/Java/JavaVirtualMachines/
    

    My Home directory was:

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

    and my Header directory was:

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

    1) The JPype script assumes that Headers is within the Home directory but it's not, so I changed the Home path var and created a new Content path var in the setup.py script - 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"]
    
    • Note that this step was mentioned as required but I did not have to do this for it to work so maybe try without it first

    3) In setupInclusion, add paths to your "Home/include" dir and your "Headers" dir:

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

    4) Running the installation should now work:

    sudo python setup.py install
    

提交回复
热议问题