Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install at Macosx lion #23

Closed
dreampuf opened this issue Aug 25, 2012 · 12 comments
Closed

Can't install at Macosx lion #23

dreampuf opened this issue Aug 25, 2012 · 12 comments

Comments

@dreampuf
Copy link

When I install the pyjnius by pip, I get the JDK 7 and install it. then when I run pip install pyjnius, it's report the error as /Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home/include/jni.h:45:10: fatal error: 'jni_md.h' file not found (after I has set the JDK_HOME and JRE_HOME)

And I find the file at '/Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home/include/darwin/` and copy it to parent directory.

Then, I retry installing, and get the result like clang: error: no such file or directory: '/Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home/jre/lib/amd64/server'.
I can't find the ire/lib/amd64/server. what can I do?

@MLnick
Copy link

MLnick commented Aug 29, 2012

Similar issues here. You can get past the above by setting:
library_dirs = ['/System/Library/Frameworks/JavaVM.framework/Libraries']
include_dirs = ['/System/Library/Frameworks/JavaVM.framework/Headers']

and commenting out the relevant assignments further down.
#include_dirs = [
# join(jdk_home, 'include'),
# join(jdk_home, 'include', 'linux')]
#library_dirs = [join(jre_home, 'lib', cpu, )] #'server')]

However, I still get this:

python setup.py build_ext --inplace -f
/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running build_ext
cythoning jnius/jnius.pyx to jnius/jnius.c
building 'jnius' extension
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -Os -w -pipe -march=native -Qunused-arguments -fwrapv -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c jnius/jnius.c -o build/temp.macosx-10.5-intel-2.7/jnius/jnius.o
/usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot / -L/usr/local/Cellar/readline/6.2.2/lib build/temp.macosx-10.5-intel-2.7/jnius/jnius.o -L/System/Library/Frameworks/JavaVM.framework/Libraries -ljvm -o /Users/Nick/workspace/python/pyjnius/jnius/jnius.so -Wl,-rpath /System/Library/Frameworks/JavaVM.framework/Libraries
ld: warning: ignoring file /System/Library/Frameworks/JavaVM.framework/Libraries/libjvm.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64)

Would be really nice to play around with this but just can't get it to work on Mac OS X

@MLnick
Copy link

MLnick commented Aug 29, 2012

After doing the above, in iPython:

In [1]: from jnius import autoclass

ImportError Traceback (most recent call last)
in ()
----> 1 from jnius import autoclass

/Users/Nick/workspace/python/pyjnius/jnius/init.py in ()
10 version = '1.1-dev'
11
---> 12 from .jnius import *
13 from .reflect import *

ImportError: dlopen(jnius/jnius.so, 2): Symbol not found: _JNI_CreateJavaVM
Referenced from: /Users/Nick/workspace/python/pyjnius/jnius/jnius.so
Expected in: dynamic lookup

@tito
Copy link
Member

tito commented Aug 31, 2012

Can you retry the compilation with the 64 bits Python?
It look like your're using the 32 bits version, and the libjvm is 64 bits.

Or the inverse, use a 32 bits jvm instead :)

@MLnick
Copy link

MLnick commented Aug 31, 2012

I'm using 64-bit Python. Forcing it:

arch -x86_64 python setup.py build_ext --inplac
e -f
/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running build_ext
cythoning jnius/jnius.pyx to jnius/jnius.c
building 'jnius' extension
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -Os -w -pipe -march=native -Qunused-arguments -fwrapv -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I/System/Library/Frameworks/JavaVM.framework/Headers -I/usr/local/Cellar/python/2.7.2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c jnius/jnius.c -o build/temp.macosx-10.5-intel-2.7/jnius/jnius.o
/usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -isysroot / -L/usr/local/Cellar/readline/6.2.2/lib build/temp.macosx-10.5-intel-2.7/jnius/jnius.o -L/System/Library/Frameworks/JavaVM.framework/Libraries -ljvm -o /Users/Nick/workspace/python/pyjnius/jnius/jnius.so -Wl,-rpath /System/Library/Frameworks/JavaVM.framework/Libraries
ld: warning: ignoring file /System/Library/Frameworks/JavaVM.framework/Libraries/libjvm.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64)

I will see if I can get a 32-bit JVM to work. But still not quite getting why it's not working.

@tito
Copy link
Member

tito commented Sep 1, 2012

Ok, maybe the jvm is already 32 bits then, and you're using a 64 bits python?
Try with 32bits python?

@ytwu
Copy link

ytwu commented Sep 9, 2012

Hi tito, you can try to down load JDK from :
http://www.oracle.com/technetwork/java/javase/downloads/jdk7u7-downloads-1836413.html

and recompile it with

10:~ ytwu$ echo $JDK_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home
10:~ ytwu$ echo $JRE_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/jre

Modified below in setup.py:

library_dirs = ['/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/jre/lib/
include_dirs = ['/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/include

you should be able to get jnius work on mac lion.

@allfro
Copy link
Contributor

allfro commented Oct 16, 2012

Hi

You can try this pull request: #42.

@dreampuf
Copy link
Author

@allfro I have use request. And it's could compile. But it throw an exception:

jnius/jnius.c:20472: error: expected ‘)’ before ‘val’
lipo: can't figure out the architecture type of: /var/folders/sr/m9lk94tn4x75p8nyg6dm31cr0000gn/T//ccyyZWp7.out
error: command 'gcc-4.2' failed with exit status 1
make: *** [build_ext] Error 1

env : mac osx lion
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)

@allfro
Copy link
Contributor

allfro commented Oct 22, 2012

@dreampuf do 'man python' for instructions on how to make your version of python run in 32-bit mode.

@dreampuf
Copy link
Author

@allfro It's must 32-bit mode? I have try VERSIONER_PYTHON_PREFER_32_BIT=yes python setup.py build_ext, and fail again.

@allfro
Copy link
Contributor

allfro commented Oct 23, 2012

Not sure but I wanted to see what would happen. Did you download the latest of pyjnius and apple jvm? Did you compile from fresh sources?

@dreampuf
Copy link
Author

@allfro I don't know what's wrong of environment.
I pull the lastest version of pyjnius and use the openjdk with osx build(http://code.google.com/p/openjdk-osx-build/).

I think my environment is broken (I'm use the homebrew and customize install path prefix of it's).
now, I have some lib was install in /usr/lib, and some one else was /myhomebrewpath/lib.
I can't install some normally python module(like scipy) manually.I need install it by DMG package, but DMG path can't customize..........

Finally, I decide to use the VM to try these.

@tito tito closed this as completed Jul 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants