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?