jpype-project / jpype Goto Github PK
View Code? Open in Web Editor NEWJPype is cross language bridge to allow Python programs full access to Java class libraries.
Home Page: http://www.jpype.org
License: Other
JPype is cross language bridge to allow Python programs full access to Java class libraries.
Home Page: http://www.jpype.org
License: Other
As proposed in #7, we need a more solid way of finding java's location throughout various *nix based systems and version (sun/oracle/openjdk).
If all else fails, we need to give the user an easy way to set it himself. Note that this has already been introduced with #10 by looking for the JAVA_HOME
environment variable. Maybe there are some other concepts we could integrate.
I wanted to share with those interested that in order to get this work with anaconda I had to create a symbolic link in /usr/lib64 between libpython2.7.so and $ANACONDA_HOME/lib/libpython.2.7.so.1.0.
I was getting an error upon installation with an inability to find the python archive:
"/usr/bin/ld cannot find -lpython2.7"
This could possibly be corrected by allowing someone to specify the ld library search path during install but creating a symbolic link worked for me.
Just noticed that installing from PyPI fails with the following message when trying to install on an Ubuntu Precise 32-bit system:
Please check that you have it installed. If you have and the destination is not
in the above list please consider opening a ticket or creating a pull request on
github: https://github.com/originell/jpype//usr/lib/jvm/default-java
/usr/lib/jvm/java-6-sun
/usr/lib/jvm/java-1.5.0-gcj-4.4
/usr/lib/jvm/jdk1.6.0_30
/usr/lib/jvm/java-1.5.0-sun-1.5.0.08
/usr/java/jdk1.5.0_05
/usr/lib/jvm/java-6-openjdk-amd64
However, the install succeeds if pulling from master, presumably because of some new globs for finding JAVA_HOME?
Would you be able to update PyPI sometime soon with an update?
For reference, here is the place that I think is being used to manage Java installations on Ubuntu 32-bit Precise:
$ ls /usr/lib/jvm
java-1.6.0-open-jdk-i386
java-6-openjdk-common
java-6-openjdk-i386
java-7-openjdk-i386
Thanks!
Despite from being extremely slow these methods also leak memory. I think we should rewrite this stuff, we can only perform better...
The JNI interface calls doe not cleanup! E.g.:
==7783== 4 bytes in 1 blocks are definitely lost in loss record 5 of 1,320
==7783== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7783== by 0x890147A: jni_GetBooleanArrayElements (in /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server/libjvm.so)
==7783== by 0x89167C0: checked_jni_GetBooleanArrayElements (in /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server/libjvm.so)
==7783== by 0x78CB4A7: JPJavaEnv::GetBooleanArrayElements(jbooleanArray, unsigned char_) (jp_javaenv_autogen.cpp:1385)
==7783== by 0x78D987F: JPBooleanType::setArrayValues(jarray, HostRef_) (jp_primitivetypes.cpp:895)
==7783== by 0x78F27E2: JPypeJavaArray::setArrayValues(object, object) (jpype_javaarray.cpp:237)
Indeed leaking a few booleans seems to be not that bad. But consider a big double array!
The following snippet does not work as expected:
import numpy as np
import jpype
jpype.startJVM(jpype.getDefaultJVMPath())
x = np.asarray([1,2,3]).astype(np.int32) # java uses 32 bit signed ints
b=jpype.nio.convertToDirectBuffer(x)
b.getInt() # outputs 16777216
b.getInt() # 33554432
b.getInt() # 50331648
I also noticed, that the test for conversion namely convtest.py is broken, since in Python2.7 the array module does not provide the buffer interface (anymore?!).
from array import array
a = array('i')
a.extend([1,2,3])
jpype.nio.convertToDirectBuffer(a)
cannot make memory view because object does not have the buffer interface
I push the code to the test enviroment , and there are another Exception.... T . T
The project in my enviroment there are no problem.
Exception in below.
Traceback (most recent call last):
File "/home/prod/softwares/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/prod/deploys/WiwideOP/libs/rsa/api/rsa_adapter.py", line 63, in wrapper
result = rsa_api.auth(user_name, pass_code)
File "/home/prod/deploys/WiwideOP/libs/rsa/api/rsa_api.py", line 26, in auth
startJVM(getDefaultJVMPath(), "-Djava.class.path=%s" % CLASS_PATH)
File "build/bdist.linux-x86_64/egg/jpype/_core.py", line 44, in startJVM
_jpype.startup(jvm, tuple(args), True)
RuntimeError: Unable to start JVM at src/native/common/jp_env.cpp:71
java version "1.6.0_32"
OpenJDK Runtime Environment (IcedTea6 1.13.4) (6b32-1.13.4-4ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
We use uwsgi to start project , is that problem?
The following snippet raises OverflowError for unknown reason:
startJVM(getDefaultJVMPath())
a=JArray(JInt, 1)([1,2,3])
a[0 : len(a)] # works
a[ : ] # raises OverflowError
running build
running build_py
running build_ext
building '_jpype' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -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 -DMACOSX=1 -Isrc/native/common/include -Isrc/native/python/include -I/System/Library/Frameworks/JavaVM.framework/Headers -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/native/common/jp_array.cpp -o build/temp.macosx-10.9-intel-2.7/src/native/common/jp_array.o
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1
python3 has been released for a while,and it is good handling UTF-8 characters.
I would recommend using https://pypi.python.org/pypi/bumpversion/ to ease the release process a little. What do you think? I found out when reading https://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/ which I can highly recommend.
Hello,
I am trying to get jpype 0.5.4.5 working on Mac osx 10.9 (mavericks) with Java JDK 1.6 and python 2.7.5. The setup with python seems to work fine without any compilation errors. However, I get the following error when trying to use the module in python:
ImportError Traceback (most recent call last)
in ()
----> 1 import jpype
/Library/Python/2.7/site-packages/jpype/init.py in ()
15 #
16 #*****************************************************************************
---> 17 from _jpackage import *
18 from _jclass import *
19 from _jarray import *
/Library/Python/2.7/site-packages/jpype/_jpackage.py in ()
16 #*****************************************************************************
17
---> 18 import _jpype
19 import _jclass
20
ImportError: dlopen(/Library/Python/2.7/site-packages/_jpype.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/_jpype.so: mach-o, but wrong architecture
I'm not actually sure how the architecture is getting messed up. Any ideas?
I’m using JPype to read some raw data from OLE2 files using the Apache POI Java library, and I have a question about data conversion. I am basically reading an array of bytes into a Java byte array (jpype._jarray.byte[]
) which I want to convert to a Numpy array. However, since the byte array does not seem to implement the buffer protocol, I have to resort to something like the following:
`numpy.fromiter(byte_array, dtype='uint8')`
Unfortunately this is quite slow when the byte array is large. As a work around, I tried using byte_array.__str__()
which is really fast, but I end up with a unicode string. This works when each byte is in the range 0-127, and otherwise the unicode representation seems to be different from the raw data (perhaps due to some kind of encoding?). Another approach is to use bytearray(byte_array)
which is also really fast, but unfortunately it only works if the bytes are in the range 0-127 (each byte is interpreted as a signed integer instead of an unsigned integer).
So my question is this: Is there a better way (i.e., quicker than using the iterator approach) to convert a Java byte array into a Numpy uint8 array?
Here's a small example:
nbytes = 2*1024**2
ByteBuffer = jpype.java.nio.ByteBuffer
bb = ByteBuffer.allocate(nbytes)
buf = bb.array()
for i in range(nbytes): buf[i] = (i % 256) - 128
# This takes 8.15 sec on my machine
a = numpy.fromiter(buf, dtype='uint8')
# This takes 11.2 ms on my machine
b = numpy.array(numpy.frombuffer(buffer(buf.__str__()),dtype='uint16'),dtype='uint8')
print a # the correct result -- but slow
[128 129 130 ..., 125 126 127]
print b # the wrong result -- but very fast
[196 197 199 ..., 125 126 127]
all tickets blocking 0.5.4.6 are solved. push it to pypi ASAP
Thanks to all of your hard work, we are slowly turning into more than just the "friendly to install jpype fork", I initially started. Man this is so great..
Ok back to topic: it would be awesome to update the README and CHANGELOG to reflect all the changes.
I would love to do this, but I completely lost track of what you all did. So it would be really really wonderful if one of you people took the time to do all that :)
Starting with fd4153c I get a core dump after executing the testsuite.
----------------------------------------------------------------------
Ran 50 tests in 0.160s
OK
Running testsuite using JVM /usr/lib/jvm/java-6-openjdk-amd64/jre//lib/amd64/server/libjvm.so
nan != 0.0 -> True == -> False
b
u'b'
foo(int) in C: 1
aaa
<class 'jpype._jclass.jpype.attr.ClassWithBuffer'>
testWithHolder
aaaaa
<class 'jpype._jarray.byte[]'> 1
12
13
Caught the exception Foo -> <class 'jpype._jclass.java.lang.RuntimeException'>
java.lang.RuntimeException: Foo
at jpype.exc.ExceptionTest.throwRuntime(Unknown Source)
Caught a Java exception ...
Caught the exception Foo
java.lang.RuntimeException: Foo
at jpype.exc.ExceptionTest.throwRuntime(Unknown Source)
if here, everything is fine
slice(2, 4, None) ['__class__', '__cmp__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'indices', 'start', 'step', 'stop']
JVM activity report :
classes loaded : 84
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000000000000, pid=4419, tid=140068300801792
#
# JRE version: 6.0_27-b27
# Java VM: OpenJDK 64-Bit Server VM (20.0-b12 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea6 1.12.6
# Distribution: Ubuntu 12.04 LTS, package 6b27-1.12.6-1ubuntu0.12.04.4
# Problematic frame:
# C 0x0000000000000000
#
# An error report file with more information is saved as:
# /tmp/jpype/hs_err_pid4419.log
#
# If you would like to submit a bug report, please include
# instructions how to reproduce the bug and visit:
# https://bugs.launchpad.net/ubuntu/+source/openjdk-6/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)
After compiling JPype with MS VC 2008 Express I get
"the program can't start because MSVCR100.dll is missing from your computer" when executing the JPype testsuite.
I can fix it following the instructions here: http://stackoverflow.com/questions/6956747/c-sharp-missing-msvcr100-dll
Anyway, it would be nice if JPype would run out of the box or if I at least could find a note in the installation/user guide.
in JPClass destructor the list of interfaces is being deleted. This may lead to undefined behaviour in other classes implementing one of those interfaces, since those wont exist anymore in a shared scenario. So we need some sort of tracking interface "refcount".
Maybe we should use smart pointers for that - which will require some work, but it seems to be the cleanest way.
Currently there is a tiny memleak, because the javatype map in JPTypeManger is not deleted.
Could this JPype package be uploaded to pypi? I'm afraid i dont know enough about pypi to help but I think it would be very nice to automatically download it with pip.
Hi,
if one converts 32 bit signed integer (default java int type) from python to JVM via jpype, there will be an integer overflow.
If one tries the same with 64 bit signed ints, the conversion succeeds.
I am on version 0.5.4.5 with java 1.7.0_51 (python and java 64 bit)
The following snippet shows the problem:
import numpy as np
from jpype import *
startJVM(getDefaultJVMPath())
a=np.zeros(10).astype(np.int32)
b=JArray(JInt)(a)
print a, b
# output [0 0 0 0 0 0 0 0 0 0] (51721472, 51721472, 51721472, 51721472, 51721472, 51721472, 51721472, 51721472, 51721472, 51721472)
a=np.zeros(10).astype(np.int64)
b=JArray(JInt)(a)
print a, b
# output [0 0 0 0 0 0 0 0 0 0] (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
I tried to install the current version with pip and got the following error:
src/native/common/include/jpype.h:45:17: fatal error: jni.h: No such file or directory
The file was not existing on my computer. I found it in the package openjdk-6-jdk which I installed. The documentation could mention that a JDK is required (if that is really the case).
Now jni.h is in /usr/lib/jvm/java-6-openjdk-amd64/include/jni.h
but the error remains the same.
I run xubuntu 12.10 and have openjdk-6-jre and openjdk-6-jdk installed. I dont have a JAVA_HOME set.
Hello,
I am trying to run this command inside python console:
import jpype
jpype.isThreadAttachedToJVM()
Segmentation fault
Python Crashes and here's the Report I can see on MacOS... (sorry for the long trail)
We saw this issue when using python-boilerpipe and this line seems to be the culprit. Any help would be greatly appreciated...
Process: Python [20689]
Path: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: ??? (???)
Code Type: X86-64 (Native)
Parent Process: bash [6859]
Date/Time: 2014-01-08 18:08:35.278 +0530
OS Version: Mac OS X 10.6.8 (10K549)
Report Version: 6
Interval Since Last Report: 2915 sec
Crashes Since Last Report: 11
Per-App Crashes Since Last Report: 11
Anonymous UUID: CE1496F8-7C2D-4418-A354-1BCB42493EC9
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 _jpype.so 0x000000010058fbb2 JPJavaEnv::isThreadAttached() + 18 (jp_javaenv.cpp:245)
1 _jpype.so 0x000000010058bc89 JPEnv::isThreadAttached() + 9 (jp_env.cpp:96)
2 _jpype.so 0x00000001005c4c49 JPypeModule::isThreadAttached(_object*) + 25 (jpype_module.cpp:235)
3 org.python.python 0x00000001000c25c2 PyEval_EvalFrameEx + 20962
4 org.python.python 0x00000001000c33ca PyEval_EvalFrameEx + 24554
5 org.python.python 0x00000001000c4786 PyEval_EvalCodeEx + 2118
6 org.python.python 0x00000001000c48a6 PyEval_EvalCode + 54
7 org.python.python 0x00000001000e8c5c PyRun_InteractiveOneFlags + 380
8 org.python.python 0x00000001000e8ebe PyRun_InteractiveLoopFlags + 78
9 org.python.python 0x00000001000e96d1 PyRun_AnyFileExFlags + 161
10 org.python.python 0x000000010010044d Py_Main + 3101
11 org.python.python 0x0000000100000f14 0x100000000 + 3860
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x0000000000000000 rcx: 0x0000000000000004 rdx: 0x00000001005fc580
rdi: 0x0000000000000000 rsi: 0x0000000000000000 rbp: 0x00007fff5fbfe8c0 rsp: 0x00007fff5fbfe8b0
r8: 0x00000001003fc0a0 r9: 0x00000001003fc0a4 r10: 0x0000000000000033 r11: 0x0000000000000000
r12: 0x0000000100393120 r13: 0x00000001003037d0 r14: 0x0000000100392fa0 r15: 0x00000001004a7f38
rip: 0x000000010058fbb2 rfl: 0x0000000000010202 cr2: 0x0000000000000008
Binary Images:
0x100000000 - 0x100000fff +org.python.python 2.7.6 (2.7.6) /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
0x100003000 - 0x10016efe7 +org.python.python 2.7.6, (c) 2004-2013 Python Software Foundation. (2.7.6) <96E177D6-BA68-399D-7325-FAA0DD7247EB> /Library/Frameworks/Python.framework/Versions/2.7/Python
0x1002f0000 - 0x1002f2ff7 +readline.so ??? (???) /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so
0x1004f0000 - 0x10050cfe7 libedit.2.dylib 2.11.0 (compatibility 2.0.0) /usr/lib/libedit.2.dylib
0x10051b000 - 0x10056ffe7 +libncursesw.5.dylib 5.0.0 (compatibility 5.0.0) <3F0079C0-01C1-3CB8-19CA-F9B49AA4F4A4> /Library/Frameworks/Python.framework/Versions/2.7/lib/libncursesw.5.dylib
0x100580000 - 0x1005f9ff7 +_jpype.so ??? (???) <0C9CD115-EEF9-A9CD-A8E5-641D3FF14F9E> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_jpype.so
0x100644000 - 0x100648ff7 +operator.so ??? (???) /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/operator.so
0x10064f000 - 0x100654fff +array.so ??? (???) <8B605F47-04D1-A508-FF88-45F843C64496> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so
0x7fff5fc00000 - 0x7fff5fc3be0f dyld 132.1 (???) <29DECB19-0193-2575-D838-CF743F0400B2> /usr/lib/dyld
0x7fff8177a000 - 0x7fff817c6fff libauto.dylib ??? (???) /usr/lib/libauto.dylib
0x7fff85056000 - 0x7fff85095fef libncurses.5.4.dylib 5.4.0 (compatibility 5.4.0) <9D53BE03-6D81-D0CB-F657-4E842E69A66A> /usr/lib/libncurses.5.4.dylib
0x7fff859aa000 - 0x7fff85a60ff7 libobjc.A.dylib 227.0.0 (compatibility 1.0.0) <03140531-3B2D-1EBA-DA7F-E12CC8F63969> /usr/lib/libobjc.A.dylib
0x7fff8620d000 - 0x7fff86384fe7 com.apple.CoreFoundation 6.6.6 (550.44) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff8824b000 - 0x7fff8825cff7 libz.1.dylib 1.2.3 (compatibility 1.0.0) <97019C74-161A-3488-41EC-A6CA8738418C> /usr/lib/libz.1.dylib
0x7fff88a1f000 - 0x7fff88bddfff libicucore.A.dylib 40.0.0 (compatibility 1.0.0) <97A75BFB-0DB6-6F44-36B0-97B7F7208ABB> /usr/lib/libicucore.A.dylib
0x7fff88c8a000 - 0x7fff88d07fef libstdc++.6.dylib 7.9.0 (compatibility 7.0.0) <35ECA411-2C08-FD7D-11B1-1B7A04921A5C> /usr/lib/libstdc++.6.dylib
0x7fff88d08000 - 0x7fff88d0cff7 libmathCommon.A.dylib 315.0.0 (compatibility 1.0.0) <95718673-FEEE-B6ED-B127-BCDBDB60D4E5> /usr/lib/system/libmathCommon.A.dylib
0x7fff88d0d000 - 0x7fff88ecefef libSystem.B.dylib 125.2.11 (compatibility 1.0.0) <9AB4F1D1-89DC-0E8A-DC8E-A4FE4D69DB69> /usr/lib/libSystem.B.dylib
0x7fffffe00000 - 0x7fffffe01fff libSystem.B.dylib ??? (???) <9AB4F1D1-89DC-0E8A-DC8E-A4FE4D69DB69> /usr/lib/libSystem.B.dylib
Model: MacBookPro8,2, BootROM MBP81.0047.B27, 4 processors, Intel Core i7, 2 GHz, 4 GB, SMC 1.69f1
Graphics: AMD Radeon HD 6490M, AMD Radeon HD 6490M, PCIe, 256 MB
Graphics: Intel HD Graphics 3000, Intel HD Graphics 3000, Built-In, 384 MB
Memory Module: global_name
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xD6), Broadcom BCM43xx 1.0 5.100.198.104.5)
Bluetooth: Version 2.4.5f3, 2 service, 12 devices, 1 incoming serial ports
Network Service: AirPort, AirPort, en1
Serial ATA Device: Hitachi HTS545050B9A302, 465.76 GB
Serial ATA Device: MATSHITADVD-R UJ-898
USB Device: FaceTime HD Camera (Built-in), 0x05ac (Apple Inc.), 0x8509, 0xfa200000 / 3
USB Device: Hub, 0x0424 (SMSC), 0x2513, 0xfa100000 / 2
USB Device: BRCM2070 Hub, 0x0a5c (Broadcom Corp.), 0x4500, 0xfa110000 / 5
USB Device: Bluetooth USB Host Controller, 0x05ac (Apple Inc.), 0x821a, 0xfa113000 / 8
USB Device: Apple Internal Keyboard / Trackpad, 0x05ac (Apple Inc.), 0x0245, 0xfa120000 / 4
USB Device: Hub, 0x0424 (SMSC), 0x2513, 0xfd100000 / 2
USB Device: IR Receiver, 0x05ac (Apple Inc.), 0x8242, 0xfd110000 / 3
Would be nice to be able to build jpype without Visual Studio.
Downloading/unpacking jpype1
Running setup.py (path:C:\Sources\jpype_env\build\jpype1\setup.py) egg_info for package jpype1
C:\Python27\Lib\distutils\extension.py:133: UserWarning: Unknown Extension options: 'library_dir'
warnings.warn(msg)
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "C:\Sources\jpype_env\build\jpype1\setup.py", line 178, in <module>
ext_modules=[jpypeLib],
File "C:\Python27\Lib\distutils\core.py", line 151, in setup
dist.run_commands()
File "C:\Python27\Lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "<string>", line 15, in replacement_run
File "C:\Sources\jpype_env\lib\site-packages\setuptools\command\egg_info.py", line 186, in find_sources
mm.run()
File "C:\Sources\jpype_env\lib\site-packages\setuptools\command\egg_info.py", line 246, in run
self.add_defaults()
File "C:\Sources\jpype_env\lib\site-packages\setuptools\command\egg_info.py", line 282, in add_defaults
sdist.add_defaults(self)
File "C:\Sources\jpype_env\lib\site-packages\setuptools\command\sdist.py", line 179, in add_defaults
build_ext = self.get_finalized_command('build_ext')
File "C:\Python27\Lib\distutils\cmd.py", line 311, in get_finalized_command
cmd_obj = self.distribution.get_command_obj(command, create)
File "C:\Python27\Lib\distutils\dist.py", line 846, in get_command_obj
cmd_obj = self.command_obj[command] = klass(self)
File "C:\Python27\Lib\distutils\cmd.py", line 64, in __init__
self.initialize_options()
File "C:\Sources\jpype_env\build\jpype1\setup.py", line 142, in initialize_options
os.environ['OPT'] = ' '.join(flag for flag in opt.split()
AttributeError: 'NoneType' object has no attribute 'split'
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info\JPype1.egg-info
writing pip-egg-info\JPype1.egg-info\PKG-INFO
writing top-level names to pip-egg-info\JPype1.egg-info\top_level.txt
writing dependency_links to pip-egg-info\JPype1.egg-info\dependency_links.txt
writing manifest file 'pip-egg-info\JPype1.egg-info\SOURCES.txt'
C:\Python27\Lib\distutils\extension.py:133: UserWarning: Unknown Extension options: 'library_dir'
warnings.warn(msg)
warning: manifest_maker: standard file '-c' not found
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "C:\Sources\jpype_env\build\jpype1\setup.py", line 178, in <module>
ext_modules=[jpypeLib],
File "C:\Python27\Lib\distutils\core.py", line 151, in setup
dist.run_commands()
File "C:\Python27\Lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\Lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "<string>", line 15, in replacement_run
File "C:\Sources\jpype_env\lib\site-packages\setuptools\command\egg_info.py", line 186, in find_sources
mm.run()
File "C:\Sources\jpype_env\lib\site-packages\setuptools\command\egg_info.py", line 246, in run
self.add_defaults()
File "C:\Sources\jpype_env\lib\site-packages\setuptools\command\egg_info.py", line 282, in add_defaults
sdist.add_defaults(self)
File "C:\Sources\jpype_env\lib\site-packages\setuptools\command\sdist.py", line 179, in add_defaults
build_ext = self.get_finalized_command('build_ext')
File "C:\Python27\Lib\distutils\cmd.py", line 311, in get_finalized_command
cmd_obj = self.distribution.get_command_obj(command, create)
File "C:\Python27\Lib\distutils\dist.py", line 846, in get_command_obj
cmd_obj = self.command_obj[command] = klass(self)
File "C:\Python27\Lib\distutils\cmd.py", line 64, in __init__
self.initialize_options()
File "C:\Sources\jpype_env\build\jpype1\setup.py", line 142, in initialize_options
os.environ['OPT'] = ' '.join(flag for flag in opt.split()
AttributeError: 'NoneType' object has no attribute 'split'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in C:\Sources\jpype_env\build\jpype1
Storing debug log for failure in C:\Users\foobar\pip\pip.log
In setViaBuffer method,
if (not err) { ... } may not compile.
if (!err) { ... } is one way to fix it.
In my case, the folder /System/Library/Frameworks/JavaVM.framework/Versions/Current contains the folder 'Headers', while the folder /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK contains the folder 'Libraries'.
As a consequence, I have to set it like this:
def setupMacOSX(self):
self.javaHome = '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents'
self.jdkInclude = ""
self.libraries = ["dl"]
self.libraryDir = [self.javaHome+"/Libraries"]
self.macros = [('MACOSX',1)]
def setupInclusion(self):
self.includeDirs = [
"/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers",
"/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers"+self.jdkInclude,
"src/native/common/include",
"src/native/python/include",
]
Any idea why this is? Am I missing something here?
Hi,
just want to ask if somebody of our maintainers can provide binary packages (maybe wheel format?) for MacOSX to avoid need for a JDK?
Best,
Martin
i found a bug.
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x00007f8968afe1b6, pid=18623, tid=140228174546752
JRE version: OpenJDK Runtime Environment (7.0_55-b14) (build 1.7.0_55-b14)
Java VM: OpenJDK 64-Bit Server VM (24.51-b03 mixed mode linux-amd64 compressed oops)
Problematic frame:
C [_jpype.so+0x3e1b6] JPJavaEnv::CallVoidMethod(jobject, jmethodID)+0x26
Core dump written. Default location: /home/keith/wiwide/project/system/branches/RSA/WiwideOP/core or core.18623
An error report file with more information is saved as:
/home/keith/wiwide/project/system/branches/RSA/WiwideOP/hs_err_pid18623.log
If you would like to submit a bug report, please include
instructions on how to reproduce the bug and visit:
http://icedtea.classpath.org/bugzilla
and code in below
# encoding=utf8
2 import jpype
3 import settings
4 import time
5
6 CLASS_PATH = "%s/authapi-8.5.jar:%s/commons-logging-1.1.1.jar:%s/cryptoj-6.1.jar:%s/log4j-1.2.12rsa-1.jar:%s/xmlsec-1.5.5.jar" % (("%s/lib
7
8 if __name__ == "__main__":
9 if not jpype.isJVMStarted():
10 jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % CLASS_PATH)
11 print "first start jvm"
12 jpype.shutdownJVM()
13 time.sleep(2)
14 jpype.shutdownJVM()
15 AuthSessionFactory = jpype.JClass("com.rsa.authagent.authapi.AuthSessionFactory")
16 if not jpype.isJVMStarted():
17 jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % CLASS_PATH)
18 print "second start jvm"
19 jpype.shutdownJVM()
first time to use it , is okay ! but when i use it again , JVM throw a Exception
so how can i fix it !
help me plz, this is very important things
system and java information in below.
java version "1.7.0_55"
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
JPype used to work without numpy, which transitively depends on a few native libraries that are not installed by default on my distros, viz.,
Since the addition of numpy JPype breaks on systems that don't have these dependencies. I see the error show up as ImportError: numpy.core.multiarray failed to import
.
Can we make the numpy dependency optional, and default to old behavior?
I am attempting to install JPype1 with the following command on linux:
sudo pip install jpype1
The following folders exist on my drive (result ls -l output on /usr/lib/jvm):
mintuser@linuxmint /usr/lib/jvm $ ls -l
total 12
lrwxrwxrwx 1 root root 23 Jul 20 2013 default-java -> java-1.7.0-openjdk-i386
lrwxrwxrwx 1 root root 19 Jul 20 2013 java-1.7.0-openjdk-i386 -> java-7-openjdk-i386
drwxr-xr-x 5 root root 4096 Apr 25 2013 java-6-openjdk-i386
drwxr-xr-x 3 root root 4096 Apr 25 2013 java-7-openjdk-common
drwxr-xr-x 5 root root 4096 Apr 25 2013 java-7-openjdk-i386
When installing jpype1 module I get the following error:
No JAVA_HOME Environment Variable set. Trying to guess it...
********************************************************************************
No Java/JDK could be found. I looked in the following directories:
/usr/lib/jvm/java-7-openjdk-common
/usr/lib/jvm/java-7-openjdk-i386
/usr/lib/jvm/default-java
/usr/lib/jvm/java-1.7.0-openjdk-i386
/usr/lib/jvm/java-6-openjdk-i386
Please check that you have it installed.
Hi,
since OpenJDK is licensed under GPLv2 with classpath exception, I wonder if its possible to include the headers of JNI in the repository. It seems that mixing GPL and Apache licensed code is only allow in one direction (what I've red so far). I must admit that I'am no expert in license questions.
But it would make the installation process very easy (especially for those mac users, who don’t read the documentation), since a whole JDK is not needed for installation anymore.
If it is not legal to include it, because the code is licensed under Apache, we might consider re-licensing under GPL?
When I try to build on OSX, it fails with this error:
src/native/common/jp_primitivetypes_autogen.cpp:54:39: error: unknown type name 'uint'
setViaBuffer(jarray array, int start, uint length, PyObject* sequence, setFnc setter) {
^
src/native/common/jp_primitivetypes_autogen.cpp:124:5: error: unknown type name 'uint'
uint len = hi - lo;
^
It works in earlier releases, but not the current HEAD.
I found that it would build successfully with the following:
index f8033b0..e754259 100644
--- a/src/native/common/jp_primitivetypes_autogen.cpp
+++ b/src/native/common/jp_primitivetypes_autogen.cpp
@@ -20,6 +20,7 @@
// but has been edited already a lot, maybe we should change the name of this unit?
#include <Python.h>
#include <jpype.h>
+#ifdef MACOSX
+#include <sys/types.h>
+#endif
#ifdef HAVE_NUMPY
#define PY_ARRAY_UNIQUE_SYMBOL jpype_ARRAY_API
System info:
Java 1.6 using export JAVA_HOME=
/usr/libexec/java_home -v '1.6*'``
Python 2.7.8, Anaconda distribution
As a heads up, I tried building last night with a system that didn't have Java so I installed Open JDK 7 and the build failed because it was looking in paths for a Java 6 installation.
I am not sure if you were aware, so I just wanted to let you know. It does not appear that a build will work with Java 7.
If this sounds like a surprise, let me know, and I can provide more detail. However, it should be very easy to reproduce by trying to build with a system that only has Java 7 on it.
invalid.
Hi when I call
jpype.getDefaultJVMPath()
I get the following value:
'/usr/java/jre1.5.0_05/lib/i386/client/libjvm.so'
which doesn't exist on my computer, I use openjdk7.
Hi,
The JVM lookup code in jPype seems to be too much hard-coded.
The getDefaultJVMPath() method should have a more similar behaviour on all systems, i.e. looking for the JAVA_HOME, then the predefined locations.
Also, it should not find in locations with a predefined JVM version number.
In my Python 3 fork of this project, I've written a more "JVM version tolerant" lookup, based on class inheritance, looking for a Java installation in the following order:
The commit is here: tcalmant@40a1b98
It should be easy to convert back to Python 2, as the only Python 3 feature I use is the relative import.
Cheers,
Thomas
We should catch this case and display a proper message.
We should provide a more userfriendly API to JPype. Currently users often report more or less the same kind of errors regarding classpath setup, jvm startup/shutdown and the like.
I started to write a Whitepaper for a userfriendly JPype API in the wiki (very early draft). Feel free to add your comments or enhance it as you like.
@tcalmant reported via mail that he found jpype crashing in multi-threading environments. I put this here because I think it's better to have it publicly in the bug tracker than in emails :)
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x000000010007168a, pid=828, tid=40963
JRE version: OpenJDK Runtime Environment (7.0-b01) (build 1.7.0-u40-unofficial-b1)
Java VM: OpenJDK 64-Bit Server VM (24.0-b50 mixed mode bsd-amd64 compressed oops)
Problematic frame:
C [Python+0x6e68a] subtype_dealloc+0xdaFailed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
If you would like to submit a bug report, please include
instructions on how to reproduce the bug and visit:
http://icedtea.classpath.org/bugzilla
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.
He fixed it in one of his commits
Now we only need to test this with the changes from #17. Sadly I can't reproduce the error myself as it seems. So help is appreciated! :)
I would really like to add you all as maintainer of the pypi JPype1 package. Hence you would be able to release new versions without me.
If you could comment here with your pypi username (or create one if you don't have one) so I can add you :)
not a blocker for a new release, but we should change this someday :)
After compiling JPype on Windows XP (32 bit) with VC 2008 Express I get errors (FAILED (failures=1, errors=4, skipped=9)
) when running the testsuite with python test/testsuite.py
. This doesn't happen if I test against jpype compiled with mingw32.
.E........FEE..E...sssssss.....................................................sTest Method = 32
Test Method2 = Fooo!
.Test Method = 42
Test Method2 = Bar
.sWaiting for thread to finish
Thread has finished
..['jpypetest.array', 'jpypetest.attr', 'jpypetest.common', 'jpypetest.exc', 'jpypetest.mro', 'jpypetest.numeric', 'jpypetest.objectwrapper', 'jpypetest.properties', 'jpypetest.proxy', 'jpypetest.serial']
Running testsuite using JVM C:\Programme\Java\jre7\bin\client\jvm.dll
b
u'b'
foo(int) in C: 1
aaa
<class 'jpype._jclass.jpype.attr.ClassWithBuffer'>
testWithHolder
Caught the exception Foo -> <class 'jpype._jclass.java.lang.RuntimeException'>
java.lang.RuntimeException: Foo
at jpype.exc.ExceptionTest.throwRuntime(Unknown Source)
Caught a Java exception ...
Caught the exception Foo
java.lang.RuntimeException: Foo
at jpype.exc.ExceptionTest.throwRuntime(Unknown Source)
if here, everything is fine
======================================================================
ERROR: testByteArrayIntoVector (jpypetest.array.ArrayTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Sources\jpype\test\jpypetest\array.py", line 104, in testByteArrayIntoVector
ba = jpype.JArray(jpype.JByte)('123')
File "build\bdist.win32\egg\jpype\_jarray.py", line 81, in _jarrayInit
_jpype.setArraySlice(self.__javaobject__, 0, sz, values)
RuntimeError: Unable to convert. at src\native\common\jp_array.cpp:75
======================================================================
ERROR: testJArrayConversionDouble (jpypetest.array.ArrayTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Sources\jpype\test\jpypetest\array.py", line 168, in testJArrayConversionDouble
jarr = jpype.JArray(jpype.JDouble)(self.VALUES)
File "build\bdist.win32\egg\jpype\_jarray.py", line 81, in _jarrayInit
_jpype.setArraySlice(self.__javaobject__, 0, sz, values)
RuntimeError: Unable to convert. at src\native\common\jp_array.cpp:75
======================================================================
ERROR: testJArrayConversionFloat (jpypetest.array.ArrayTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Sources\jpype\test\jpypetest\array.py", line 160, in testJArrayConversionFloat
jarr = jpype.JArray(jpype.JFloat)(self.VALUES)
File "build\bdist.win32\egg\jpype\_jarray.py", line 81, in _jarrayInit
_jpype.setArraySlice(self.__javaobject__, 0, sz, values)
RuntimeError: Unable to convert. at src\native\common\jp_array.cpp:75
======================================================================
ERROR: testJArrayConversionShort (jpypetest.array.ArrayTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Sources\jpype\test\jpypetest\array.py", line 134, in testJArrayConversionShort
result = jarr[0 : len(jarr)]
File "build\bdist.win32\egg\jpype\_jarray.py", line 44, in __len__
return _jpype.getArrayLength(self.__javaobject__)
TypeError: Cannot convert value to Java short
======================================================================
FAIL: testJArrayConversionChar (jpypetest.array.ArrayTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Sources\jpype\test\jpypetest\array.py", line 119, in testJArrayConversionChar
self.assertEqual(str(v[:]), 'avcd')
AssertionError: "[u'a', u'v', u'c', u'd']" != 'avcd'
----------------------------------------------------------------------
Ran 85 tests in 0.671s
FAILED (failures=1, errors=4, skipped=9)
JVM activity report :
classes loaded : 97
JVM has been shutdown
Hi,
I am working with mscherer on a project using jpype. I tried to install jpype from a fresh clone from github. I discovered the in forums mentioned missing 'jni.h' file issue.
Apparently mscherer had started to fix this, but mixed two solutions. I changed locally this in setup.py
elif osx in ('10.7', '10.8', '10.9') and not os.getenv('JAVA_HOME'):
java_home = '/System/Library/Frameworks/JavaVM.framework/'
platform_specific['libraries'] = ['dl']
platform_specific['library_dir'] = [os.path.join(java_home, '/Home/lib')]
as it is mentioned in the
http://stackoverflow.com/questions/8525193/cannot-install-jpype-on-os-x-lion-to-use-with-neo4j
post. Apparently (at least in my MAC OS installation of 10.9.1) the folder
/System/Library/Frameworks/JavaVM.framework/
contains links to all current JAVA Versions. The subfolder Home points to
the home folder of the current JDK, which is the one needed for the jni.h
Maybe this helps! Best, JH
If one enables the "-Xcheck:jni" option, the JVM (java7) complains about this:
WARNING in native method: JNI FindClass received a bad class descriptor "Ljava/lang/Byte;". A correct class descriptor has no leading "L" or trailing ";". Incorrect descriptors will not be accepted in future releases.
FATAL ERROR in native method: Invalid local JNI handle passed to DeleteLocalRef
I just noticed we are missing a license. Which one would you prefer @DevilWolf? (http://choosealicense.com/)
If one uses a Java pattern which I have added at this testcase:
marscher/jpype@ab3b807
It _properties.py raises an AttributeError: 'property' object has no attribute 'isBeanMutator'
ERROR: testprovokateBug (jpypetest.properties.PropertiesTestCase)
Traceback (most recent call last):
File "/home/marscher/sources/jpype/test/jpypetest/properties.py", line 64, in testprovokateBug
t = self.jpype.properties.TestProp.factory(arr)
File "/home/marscher/.local/lib/python2.7/site-packages/jpype/_jclass.py", line 68, in _getClassFor
pyJavaClass = _JavaClass(javaClass)
File "/home/marscher/.local/lib/python2.7/site-packages/jpype/_jclass.py", line 168, in new
i.customize(name, jc, bases, members)
File "/home/marscher/.local/lib/python2.7/site-packages/jpype/_properties.py", line 70, in customize
accessor_pairs = _extract_accessor_pairs(members)
File "/home/marscher/.local/lib/python2.7/site-packages/jpype/_properties.py", line 54, in _extract_accessor_pairs
elif access == 'set' and member.isBeanMutator():
AttributeError: 'property' object has no attribute 'isBeanMutator'
(opt,) = get_config_vars('OPT')
os.environ['OPT'] = ' '.join(flag for flag in opt.split() if flag != '-Wstrict-prototypes')
'opt' must be checked for null values, otherwise the script may fail.
You can find pretty decent JPype documentation at http://jpype.sourceforge.net/doc/user-guide/userguide.html
It would be nice to add it to the repo. As the next step we should convert it to rst and update it a little and make it available at readthedocs.
We didn't notice that, because travis currently uses 2.7.3. But this will be updated soon. It seems it happens somewhere in finalization code. Thats the stacktrace in current Python:
#0 0x00007ffff6f06f79 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff6f0a388 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x0000000000557f5f in Py_FatalError ()
#3 0x00000000005537f7 in PyThreadState_Get ()
#4 0x00000000004b108b in subtype_dealloc ()
#5 0x000000000048dc57 in _Py_Dealloc ()
#6 0x00007ffff65684b2 in PythonHostEnvironment::releaseRef(void*) () at src/native/python/py_hostenv.cpp:33
#7 0x00007ffff653072f in HostRef::~HostRef() () at src/native/common/jp_env.cpp:332
#8 0x00007ffff653075e in HostRef::~HostRef() () at src/native/common/jp_env.cpp:333
#9 0x00007ffff65307ea in HostRef::release() () at src/native/common/jp_env.cpp:342
#10 0x00007ffff652ffbe in JPCleaner::~JPCleaner() () at src/native/common/jp_env.cpp:209
#11 0x00007ffff6548532 in Java_jpype_JPypeInvocationHandler_hostInvoke(JNIEnv_*, _jclass*, _jstring*, long, _jobjectArray*, _jobjectArray*, _jclass*) () at src/native/common/jp_proxy.cpp:138
The latest version of jpype1 is failing to install for me with the following error. Has anyone else seen this or can reproduce?
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Isrc/native/common/include -Isrc/native/python/include -I/export/apps/jdk/JDK-1_6_0_27/include -I/export/apps/jdk/JDK-1_6_0_27/include/linux -I/usr/include/python2.6 -c src/native/common/jp_primitivetypes_autogen.cpp -o build/temp.linux-x86_64-2.6/src/native/common/jp_primitivetypes_autogen.o
src/native/common/jp_primitivetypes_autogen.cpp: In member function ‘virtual PyObject* JPBooleanType::getArrayRangeToSequence(_jarray*, int, int)’:
src/native/common/jp_primitivetypes_autogen.cpp:1363: error: ‘NPY_BOOL’ was not declared in this scope
error: command 'gcc' failed with exit status 1
$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
$ uname -a
Linux sholsapp-ld 2.6.32-358.6.2.el6.x86_64 #1 SMP Tue May 14 15:48:21 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.