[英]Error installing pyjnius, “jni.h” not found. (OS X 10.10.1)
I have been trying to install pyjnius on OS X 10.10.1. 我一直在尝试在OS X 10.10.1上安装pyjnius。 Other dependencies taken care of, I haven't been able to solve the issue of the header file "jni.h" not being found.
其他依赖关系照顾,我还没有能够解决头文件“jni.h”没有找到的问题。 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.] [如果它有任何区别,我尝试使用pip,但它会以相同的错误终止。]
The Java versions installed are 1.6.0.65 and 1.8.0.25. 安装的Java版本是1.6.0.65和1.8.0.25。 I can switch between them if required.
如果需要,我可以在它们之间切换。
If it helps, I was able to find jni.h
using locate
. 如果它有帮助,我能够使用
locate
找到jni.h
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
. 我导航到
/System/Library/Frameworks/JavaVM.Framework/Versions/A
,并创建了一个名为Headers
的目录。 I then symlinked to jni.h
. 然后我将
jni.h
链接到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
. 运行安装脚本然后再次抛出一个错误,这次是一个
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
. 我再次运行安装程序,现在可以
import jnius
。
If anyone has an easier workaround, do post it. 如果有人有更容易的解决方法,请发布它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.