I have been trying to install pyjnius on OS X 10.10.1. Other dependencies taken care of, I haven't been able to solve the issue of the header file "jni.h" not being found. Here's what happens:
$ sudo python setup.py install
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running install
running build
running build_py
running build_ext
skipping 'jnius/jnius.c' Cython extension (up-to-date)
building 'jnius' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c jnius/jnius.c -o build/temp.macosx-10.10-intel-2.7/jnius/jnius.o
jnius/jnius.c:238:10: fatal error: 'jni.h' file not found
#include "jni.h"
^
1 error generated.
error: command 'cc' failed with exit status 1
[If it makes any difference, I have tried using pip, but it terminates with the same error.]
The Java versions installed are 1.6.0.65 and 1.8.0.25. I can switch between them if required.
If it helps, I was able to find jni.h
using locate
. It's located here:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/include/jni.h
Any help will be appreciated!
Okay, so it turns out I was pretty close to the answer. I navigated to /System/Library/Frameworks/JavaVM.Framework/Versions/A
, and created a directory called Headers
. I then symlinked to jni.h
.
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h jni.h
Running the setup script then again threw an error, this time for one jni_md.h
. Symlinking again,
ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni_md.h jni_md.h
- it worked! I ran the setup again, and can now import jnius
.
If anyone has an easier workaround, do post it.