Nellaker-group / happy

MIT License
9 stars 0 forks source link

java version #13

Closed brainfo closed 1 day ago

brainfo commented 5 days ago

Hi, I encountered the failed error when installing javabridge. I tried to first install openjdk-8 or 11 or 17 and export $JAVA_HOME respectively but no one worked

  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for javabridge (setup.py) ... error
  ERROR: Failed building wheel for javabridge
  Running setup.py clean for javabridge
Failed to build javabridge
ERROR: Could not build wheels for javabridge, which is required to install pyproject.toml-based projects

I tried to download the javabridge-1.0.19.tar.gz and python setup.py install still not working. And this gave more specific error messages:

_javabridge.c:27720:5: error: lvalue required as increment operand
27720 |     ++Py_REFCNT(o);
      |     ^~

I'm with python 3.10 on Ubuntu 22.04.3 LTS and installed like this:

apt-get install build-essential python3-dev
apt-get install python3-pil python3-pygraphviz
apt install openjdk-11-jdk
pip3 install javabridge --no-cache-dir

Could you specify the OpenJDK version and javabridge version that should work in this case?

Thanks, brainfo

cvanea commented 1 day ago

Hi @brainfo!

Javabridge can be quite tricky to install, I've been tempted to remove bioformats support for this reason. But let's see what we can do.

So you shouldn't need to install javabridge directly as python-bioformats==4.0.7 in the requirements.txt should install it, but it'll only work if it can find the jvm.

Let's check that it can find the jvm to start with. When I run java --version on Ubuntu 20.04.2 I get:

openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

If you don't see something similar then you will need to export $JAVA_HOME and check the version again to see that it worked. I can find my java location using readlink -f $(which java) which points me to /usr/lib/jvm/java-11-openjdk-amd64/bin/java so JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64.

Once it's correctly found your jvm location you can try the installation again.

Assuming this wasn't the problem you can try installing python-javabridge directly: pip install python-javabridge==4.0.3 or from github with:

pip install git+https://github.com/LeeKamentsky/python-javabridge.git#egg=javabridge

The javabridge PyPI package is outdated so python-javabridge should be used instead. Make sure to remove javabridge first.

Let me know if that works for you!

brainfo commented 1 day ago

Hi @brainfo!

Javabridge can be quite tricky to install, I've been tempted to remove bioformats support for this reason. But let's see what we can do.

So you shouldn't need to install javabridge directly as python-bioformats==4.0.7 in the requirements.txt should install it, but it'll only work if it can find the jvm.

Let's check that it can find the jvm to start with. When I run java --version on Ubuntu 20.04.2 I get:

openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

If you don't see something similar then you will need to export $JAVA_HOME and check the version again to see that it worked. I can find my java location using readlink -f $(which java) which points me to /usr/lib/jvm/java-11-openjdk-amd64/bin/java so JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64.

Once it's correctly found your jvm location you can try the installation again.

Assuming this wasn't the problem you can try installing python-javabridge directly: pip install python-javabridge==4.0.3 or from github with:

pip install git+https://github.com/LeeKamentsky/python-javabridge.git#egg=javabridge

The javabridge PyPI package is outdated so python-javabridge should be used instead. Make sure to remove javabridge first.

Let me know if that works for you!

Hi Thanks! it worked as what you suggested!