Error installing pyjnius, "jni.h" was not found. (OS X 10.10.1)

I am trying to install pyjnius on OS X 10.10.1. Other worries I care about, I was unable to resolve the issue with the header "jni.h" not found. Here's what's going on:

$ 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 matters, I tried using pip, but it fails with the same error.]

Installed Java versions: 1.6.0.65 and 1.8.0.25. I can switch between them if necessary.

If it helps, I was able to find jni.h

using locate

. It is 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 would be appreciated!

+3


source to share


1 answer


Ok, so it turned out that I was close to the answer. I went to /System/Library/Frameworks/JavaVM.Framework/Versions/A

and created a directory named Headers

. Then I am symbolically attached 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

      

By running the setup script, run the error again, this time in one jni_md.h

. Symbolizing 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 please post it.

+2


source







All Articles