Python-javabridge installation problems

49 views
Skip to first unread message

Dario Martinez

unread,
Feb 20, 2024, 2:55:21 PMFeb 20
to python-weka-wrapper
Good morning, I am stuck with the installation of python-javabridge, I have installed it using install-jdk 1.1.0, also from OpenJDK, I confess that I am new to python, I am more of a C language and similar, in any case it seems to me the following error:

C:\Users\dario>pip install python-javabridge
Collecting python-javabridge
   Using cached python-javabridge-4.0.3.tar.gz (1.3 MB)
   Preparing metadata (setup.py)... error
   error: subprocess-exited-with-error

   × python setup.py egg_info did not run successfully.
   │ exit code: 1
   ╰─> [10 lines of output]
       Traceback (most recent call last):
         File "<string>", line 2, in <module>
         File "<pip-setuptools-caller>", line 34, in <module>
         File "C:\Users\dario\AppData\Local\Temp\pip-install-4_pzgr_h\python-javabridge_6e558b0456fd4faa913c1254d851c2e3\setup.py", line 412, in <module>
           ext_modules=ext_modules(),
         File "C:\Users\dario\AppData\Local\Temp\pip-install-4_pzgr_h\python-javabridge_6e558b0456fd4faa913c1254d851c2e3\setup.py", line 99, in ext_modules
           jdk_home = find_jdk()
         File "C:\Users\dario\AppData\Local\Temp\pip-install-4_pzgr_h\python-javabridge_6e558b0456fd4faa913c1254d851c2e3\javabridge\locate.py", line 215, in find_jdk
           return kjdk_current_values['JavaHome']
       KeyError: 'JavaHome'
       [end of output]

   note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

  I have changed the content of the environment variable several times and nothing, I have had it "C:\Program Files\Eclipse Adoptium\jdk-21.0.2.13-hotspot\bin" and with the slash at the end "C:\Program Files\ Eclipse Adoptium\jdk-21.0.2.13-hotspot\bin\", nothing helps, it should be noted that when I request the installation of java with the command set JAVA_HOME the following appears:
C:\Program Files\Eclipse Adoptium\jdk-21.0.2.13-hotspot\bin or with the slash at the end depending on how you fiddled with the environment variable.

If anyone helps me by guiding me to find the solution I would be very grateful.

Peter Reutemann

unread,
Feb 20, 2024, 4:56:39 PMFeb 20
to python-we...@googlegroups.com
[...]

> I have changed the content of the environment variable several times and nothing, I have had it "C:\Program Files\Eclipse Adoptium\jdk-21.0.2.13-hotspot\bin" and with the slash at the end "C:\Program Files\ Eclipse Adoptium\jdk-21.0.2.13-hotspot\bin\", nothing helps, it should be noted that when I request the installation of java with the command set JAVA_HOME the following appears:
> C:\Program Files\Eclipse Adoptium\jdk-21.0.2.13-hotspot\bin or with the slash at the end depending on how you fiddled with the environment variable.

Use this as the JAVA_HOME environment variable (the directory above "bin"):
C:\Program Files\Eclipse Adoptium\jdk-21.0.2.13-hotspot

The "bin" directory is what you would add to the PATH variable, to
make the executables available in the terminal.
The "JAVA_HOME" directory refers the total of the Java installation.
See here for example:
https://www.wikihow.com/Set-Java-Home

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, Hamilton, NZ
Mobile +64 22 190 2375
https://www.cs.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/

Dario Martinez

unread,
Feb 20, 2024, 7:26:14 PMFeb 20
to python-we...@googlegroups.com
Hello Peter, as you can see in the following images, I think I have everything configured according to the link you gave me, and the error still persists, I don't really know what is causing the error.
image.png
image.png
image.png
image.png

Libre de virus.www.avast.com

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-weka-wrapper/CAHoQ12%2BqdDreLyC4W%3DkG6y_c_nP3XeRBVyy%3Ddhi_gRMcQB3ybg%40mail.gmail.com.

Peter Reutemann

unread,
Feb 20, 2024, 7:31:55 PMFeb 20
to python-we...@googlegroups.com
[I presume that you restarted your terminal after changing the
environment variable.]

When executing the following commands in the terminal:
echo %JAVA_HOME%
It should output the content of environment variable that you defined.

Then please try this to verify that the path is correct:
"%JAVA_HOME%\bin\java" -version

Dario Martinez

unread,
Feb 20, 2024, 7:53:10 PMFeb 20
to python-we...@googlegroups.com
Yes, of course, restart after applying the changes, and create JAVA_HOME and its path, in the user and in the system, below is the result of the commands that you suggested.
image.png

Libre de virus.www.avast.com

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.

Peter Reutemann

unread,
Feb 20, 2024, 11:09:51 PMFeb 20
to python-we...@googlegroups.com

On Wed, Feb 21, 2024 at 1:53 PM Dario Martinez <dariomar...@gmail.com> wrote:
Yes, of course, restart after applying the changes, and create JAVA_HOME and its path, in the user and in the system, below is the result of the commands that you suggested.
image.png




I'm not a Windows user, so I'm not quite sure why javabridge can't find the JDK anymore (used to be able in the past).

As a temporary workaround, have thought of giving WSL2 a go, e.g., in conjunction with the latest Ubuntu image?

Dario Martinez

unread,
Feb 21, 2024, 7:11:43 AMFeb 21
to python-we...@googlegroups.com
Hello Peter, and thank you for trying to help me with this, the intention is what counts, the truth is that the problem is complex, an additional question, does Java-bridge need a particular version of Windows and/or a specific version of Python?

Libre de virus.www.avast.com

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.

Juanjo

unread,
Feb 21, 2024, 7:52:11 AMFeb 21
to python-we...@googlegroups.com
Hi Dario, sorry to hear you still got problems. For python-javabridge you need python 3.10. You can download the required files from https://fracpete.github.io/python-weka-wrapper3/install.html#windows.

Hope it helps!

Kindest Regards,

Juanjo

Dario Martinez

unread,
Feb 21, 2024, 8:13:29 AMFeb 21
to python-we...@googlegroups.com
Hello Juan, thanks for the lik, the truth is that I have already been consulting it, among many others, and I remind you that I use Anaconda and created a virtual environment for python 3.10, where I also install the other necessary plugins and nothing is resolved the problem, another member telling me how to configure the JAVA_HOME and path environment variables, but the problem still persists, the only thing I have not been able to try is with the original python-javabridge-X.Y.Z.whl files, telling me the extension .whl when I click on the page it takes me to another page where they indicate that it is no longer available, I am trying to install it with the file python-javabridge-4.0.3.tar.gz, which I found on another page, suddenly you have the whl so you can do me a favor and send it to me, it's the only thing I haven't been able to try.

Peter Reutemann

unread,
Feb 21, 2024, 3:46:31 PMFeb 21
to python-we...@googlegroups.com
On Wed, Feb 21, 2024 at 1:53 PM Dario Martinez <dariomar...@gmail.com> wrote:
Yes, of course, restart after applying the changes, and create JAVA_HOME and its path, in the user and in the system, below is the result of the commands that you suggested.
image.png

Libre de virus.www.avast.com


This worked for me in a Windows VM:

set JDK_HOME environment variable to the same value as the JAVA_HOME one, eg:
set JDK_HOME=%JAVA_HOME%

download/install visual c++ build tools
https://visualstudio.microsoft.com/visual-cpp-build-tools/
- select "Desktop development with C++"
- install

conda environment using 3.9 (otherwise: Cannot open include file: 'longintrepr.h': No such file or directory)
conda create -n pww3 python=3.9

Then I was able to install python-javabridge.

python-javabridge does not seem to support later versions of Python (yet):

Dario Martinez

unread,
Feb 21, 2024, 4:48:46 PMFeb 21
to python-we...@googlegroups.com
Ok, thank you, I'm going to do what you tell me, could you confirm if this is the version of Java Bridge that I should install? I didn't find any more python-javabridge 4.0.3 ??, in the link: https://pypi.org/project /python-javabridge/#modal-close

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.

Peter Reutemann

unread,
Feb 21, 2024, 4:55:21 PMFeb 21
to python-we...@googlegroups.com
> Ok, thank you, I'm going to do what you tell me, could you confirm if this is the version of Java Bridge that I should install? I didn't find any more python-javabridge 4.0.3 ??, in the link: https://pypi.org/project /python-javabridge/#modal-close

Yes, 4.0.3 is the one that I installed as well.

Dario Martinez

unread,
Feb 21, 2024, 5:20:57 PMFeb 21
to python-we...@googlegroups.com
I thank you very much Peter, now if you allowed me to install the javabridge and also the python-weka-wrapper3 0.2.14 library, which is the one I finally needed to use, additionally I can tell you that everything was installed without problems in python 3.10

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.

Peter Reutemann

unread,
Feb 21, 2024, 5:24:46 PMFeb 21
to python-we...@googlegroups.com
> I thank you very much Peter, now if you allowed me to install the javabridge and also the python-weka-wrapper3 0.2.14 library, which is the one I finally needed to use, additionally I can tell you that everything was installed without problems in python 3.10

Good to know that 3.10 works as well. python-javabridge didn't compile
under 3.11.

Dario Martinez

unread,
Feb 22, 2024, 7:18:59 AMFeb 22
to python-we...@googlegroups.com
If so, and again thank you very much, I take this opportunity to ask you about something that happens to me when I run the code that I have to start testing in Notebook, the first time I run it it appears:
DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Classpath=['C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\Lib\\site-packages\\javabridge\\jars\\rhino-1.7R4.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\Lib\\site-packages\\javabridge\\jars\\runnablequeue.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\Lib\\site-packages\\javabridge\\jars\\cpython.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\arpack_combined.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\core.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\mtj.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\python-weka-wrapper.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\weka.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
DEBUG:weka.core.jvm:Package support disabled
INFO:weka.core.jvm:JVM already running, call jvm.stop() first
INFO:weka.core.jvm:JVM already running, call jvm.stop() first
INFO:weka.core.jvm:JVM already running, call jvm.stop() first
INFO:weka.core.jvm:JVM already running, call jvm.stop() first

and then I get an error:
DEBUG:weka.core.jvm:Adding bundled jars
DEBUG:weka.core.jvm:Classpath=['C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\Lib\\site-packages\\javabridge\\jars\\rhino-1.7R4.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\Lib\\site-packages\\javabridge\\jars\\runnablequeue.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\Lib\\site-packages\\javabridge\\jars\\cpython.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\arpack_combined.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\core.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\mtj.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\python-weka-wrapper.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\weka.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\arpack_combined.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\core.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\mtj.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\python-weka-wrapper.jar', 'C:\\Users\\dario\\.conda\\envs\\MASTER_TRADERS_sk\\lib\\site-packages\\weka\\lib\\weka.jar']
DEBUG:weka.core.jvm:MaxHeapSize=default
DEBUG:weka.core.jvm:Package support disabled
Traceback (most recent call last):
  File "C:\Users\dario\.conda\envs\MASTER_TRADERS_sk\lib\site-packages\javabridge\jutil.py", line 286, in start_thread
    env = vm.create(args)
  File "_javabridge.pyx", line 654, in _javabridge.JB_VM.create
RuntimeError: Failed to create Java VM. Return code = -1
ERROR:javabridge.jutil:Failed to create Java VM
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[2], line 6
      4 import weka.core.jvm as jvm
      5 #jvm.stop()
----> 6 jvm.start()
      7 jvm.start(system_cp=True, packages=True)
      8 jvm.start(packages="/my/packages/are/somwhere/else")

File ~\.conda\envs\MASTER_TRADERS_sk\lib\site-packages\weka\core\jvm.py:145, in start(class_path, bundled, packages, system_cp, max_heap_size, system_info, auto_install, logging_level)
    142     logger.debug("Automatically installing missing Weka packages (based on suggestions).")
    143     automatically_install_packages = True
--> 145 javabridge.start_vm(args=args, run_headless=True, max_heap_size=max_heap_size)
    146 javabridge.attach()
    147 started = True

File ~\.conda\envs\MASTER_TRADERS_sk\lib\site-packages\javabridge\jutil.py:319, in start_vm(args, class_path, max_heap_size, run_headless)
    317 start_event.wait()
    318 if not _javabridge.get_vm().is_active():
--> 319     raise RuntimeError("Failed to start Java VM")
    320 attach()

RuntimeError: Failed to start Java VM
The code that I am applying to test is very simple and as you can see it closes the jvm at the end, which is why I do not understand the error, at the moment what I am doing when the error appears is rst the kernel, but I would like to know the cause:
import weka.core.jvm as jvm
jvm.start()
jvm.start(system_cp=True, packages=True)
jvm.start(packages="/my/packages/are/somwhere/else")
jvm.start(max_heap_size="512m")
jvm.start(system_info=True)

#data_dir = "E:/WEKA_ANALISIS_TQUANT/MASTER TRADERS/EXTRACCIONES/"
#from weka.core.converters import Loader
#loader = Loader(classname="weka.core.converters.ArffLoader")
#data = loader.load_file(data_dir + "JRIP_ANALYSIS_Ext Alcista_@ES_15 Minute_SgPoints(2.50)_1917(70)_FiltRank0_03.csv.arff")
#data.class_is_last()

#import weka.core.converters as converters
#data = converters.load_any_file(data_dir + "JRIP_ANALYSIS_Ext Alcista_@ES_15 Minute_SgPoints(2.50)_1917(70)_FiltRank0_03.csv.arff")
#data.class_is_last()

#print(data)

#DETIENE MAQUINA VIRTUAL
jvm.stop()

Libre de virus.www.avast.com

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.

Peter Reutemann

unread,
Feb 22, 2024, 2:40:35 PMFeb 22
to python-we...@googlegroups.com
> If so, and again thank you very much, I take this opportunity to ask you about something that happens to me when I run the code that I have to start testing in Notebook, the first time I run it it appears:

[...]

> The code that I am applying to test is very simple and as you can see it closes the jvm at the end, which is why I do not understand the error, at the moment what I am doing when the error appears is rst the kernel, but I would like to know the cause:
> import weka.core.jvm as jvm

The JVM cannot be restarted after it's been stopped (in the same
process). Restarting the kernel is the only way to get it running
again AFAIK. See also this earlier post:
https://groups.google.com/g/python-weka-wrapper/c/4--i37hiGX8

Dario Martinez

unread,
Feb 22, 2024, 5:30:30 PMFeb 22
to python-we...@googlegroups.com
Excellent, thank you very much for the information.

Libre de virus.www.avast.com

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.

Dario Martinez

unread,
Feb 22, 2024, 10:40:08 PMFeb 22
to python-we...@googlegroups.com
Hello Peter, could you please tell me what the format would be to enter through options=[....], the options of the JRip algorithm that is seen in the image, I think it would be options=["100", "True","False","False","3","2.0","2","2","135","True"]

image.png



Libre de virus.www.avast.com

Peter Reutemann

unread,
Feb 22, 2024, 10:50:02 PMFeb 22
to python-we...@googlegroups.com
New question new post, please. This has nothing to do with javabridge installation problems.
Reply all
Reply to author
Forward
0 new messages