Installing jpype in Mountain Lion

2024/10/4 9:30:02

I am trying to install jpype in Mountain Lion. I followed all the steps suggested in this post: How to install JPype on OS X Lion to use with Neo4j?

However, there is a glitch with Mountain Lion. I have modified the setupMacOSX() function as follows:

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

But when I run $ sudo python setup.py install I get the following error:

src/native/common/include/jpype.h:45:10: fatal error: 'jni.h' file not found

I have located the jni.h header here:

/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h

But since jni.h is not part of Mountain Lion, I have not figured out how to modify the setup.py file to fix the bug. Any suggestions?

Answer

This is on a system running OSX 10.8.5.

I modified the setup.py for JPype-0.5.4.2 and added an element to the end of the self.includeDirs list which is created in the function setupInclusion. This function is declared at line 61 for this particular version of JPype.

     def setupInclusion(self):self.includeDirs = [self.javaHome+"/include", self.javaHome+"/include/"+self.jdkInclude,"src/native/common/include","src/native/python/include",#I added this line below. The folder contains a jni.h"/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/"]

Finally I ran pip install ~/Path/To/JPype-folder/ and the installation was successful.

https://en.xdnf.cn/q/70622.html

Related Q&A

Most efficient way to index words in a document?

This came up in another question but I figured it is best to ask this as a separate question. Give a large list of sentences (order of 100 thousands):[ "This is sentence 1 as an example", &qu…

python libclang bindings on Windows fail to initialize a translation unit from sublime text

Short description: using libclang to autocomplete code does not work with python that comes bundled with Sublime Text 3.Details: A small verifiable example is in the repo on GithubIn essence, there is …

How to create a simple Gradient Descent algorithm

Im studying simple machine learning algorithms, beginning with a simple gradient descent, but Ive got some trouble trying to implement it in python. Here is the example Im trying to reproduce, Ive got …

login_required decorator on a class based view in django

I have a working class based view. But when adding @login_required I get the error:AttributeError: function object has no attribute as_viewSomething is happening to the ResultListView here:from django.…

Generic way to get primary key from declaratively defined instance in SQLAlchemy

Does SQLAlchemy offer a generic way to get the primary key from a declaratively defined instance, so that if:Base = declarative_base()class MyClass(Base):__tablename__ = mytablekey = Column(Integer, pr…

Add column after another column

How can I add a column after another column to a database using Alembic or SQLAlchemy? That would be equivalent to this SQL clause: ALTER TABLE foo CHANGE COLUMN bar bar COLUMN_DEFINITION_HERE AFTER …

Scrapy Images Downloading

My spider runs without displaying any errors but the images are not stored in the folder here are my scrapy files:Spider.py:import scrapy import re import os import urlparse from scrapy.spiders import …

A full and minimal example for a class (not method) with Python C Extension?

Everywhere, I can easily find an example about writing a method with Python C Extensions and use it in Python. Like this one: Python 3 extension example$ python3 >>> import hello >>> …

Python: Grouping into timeslots (minutes) for days of data

I have a list of events that occur at mS accurate intervals, that spans a few days. I want to cluster all the events that occur in a per-n-minutes slot (can be twenty events, can be no events). I have …

signal.alarm not triggering exception on time

Ive slightly modified the signal example from the official docs (bottom of page).Im calling sleep 10 but I would like an alarm to be raised after 1 second. When I run the following snippet it takes way…