JPype 'Unable to start JVM' error on second run

1,696 views
Skip to first unread message

Tom Hawkins

unread,
Mar 23, 2017, 9:08:20 AM3/23/17
to spyder
I'm using Spyder 3.1.3 from the Anaconda 3.4.14 distribution with Python 3.6 on 64-bit Windows 7, and I'm trying to use JPype1 0.6.2 to work with a third party software package via its Java API. The code example from the supplier, reduced to a minimal example, is:

from jpype import *

classpath
= "C:\\Program Files\\Bayes Server\\Bayes Server 7.10\\API\\Java\\bayesserver-7.10.jar"

startJVM
(getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)

# do stuff with the API here

shutdownJVM
()

This seems to work correctly when run from the Anaconda prompt, or from IDLE: the console shows that the JVM has started, some classes have been loaded, any code at 'do stuff here' runs, and the JVM shuts down again. However when I try and run this in Spyder it works once (including showing that the JVM was shut down, if in the Python console), but attempting to run it a second time gives the following error:

>>> runfile('D:/tempcode/bayesservermintest.py', wdir='D:/tempcode')
Traceback (most recent call last):

 
File "<ipython-input-2-d85ae28a48f0>", line 1, in <module>
    runfile
('D:/tempcode/bayesservermintest.py', wdir='D:/tempcode')

 
File "C:\Users\zzzzzz\AppData\Local\Continuum\Anaconda3\envs\withjpype\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
    execfile
(filename, namespace)

 
File "C:\Users\zzzzzz\AppData\Local\Continuum\Anaconda3\envs\withjpype\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
   
exec(compile(f.read(), filename, 'exec'), namespace)

 
File "D:/tempcode/bayesservermintest.py", line 13, in <module>
    startJVM
(getDefaultJVMPath(), "-Djava.class.path=%s" % classpath)

 
File "C:\Users\zzzzzz\AppData\Local\Continuum\Anaconda3\envs\withjpype\lib\site-packages\jpype\_core.py", line 50, in startJVM
    _jpype
.startup(jvm, tuple(args), True)

RuntimeError: Unable to start JVM at native\common\jp_env.cpp:78

Spyder's Python and IPython consoles both give the same error. To get it to run again I have to close the console and open a new one.

Any ideas on what's going wrong here or how I can diagnose the problem please?

Tom Hawkins

unread,
Mar 23, 2017, 10:24:15 AM3/23/17
to spyder
I should add that I've checked that getDefaultJVMPath() returns the same value whether I run the code inside or outside Spyder, and it points to Java runtime engine 1.8.0_71.

Talat Can

unread,
Jan 12, 2019, 10:06:21 PM1/12/19
to spyder
Hi,
I stucked on the same problem, it there any solution?
23 Mart 2017 Perşembe 17:24:15 UTC+3 tarihinde Tom Hawkins yazdı:
Reply all
Reply to author
Forward
0 new messages