python-javabridge icon indicating copy to clipboard operation
python-javabridge copied to clipboard

pip javabridge install error

Open kancvinu opened this issue 6 years ago • 14 comments

Trying to install javabrigde on centos and getting the below error:

pip3 install --no-cache-dir javabridge==1.0.18 Collecting javabridge==1.0.18 Downloading https://files.pythonhosted.org/packages/a6/a0/c59bccabed99b1d4ac68166c59c679b375bfca75b78688b52c541b711578/javabridge-1.0.18.tar.gz (1.3MB) 100% |################################| 1.3MB 576kB/s Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-twazq3g6/javabridge/setup.py", line 402, in ext_modules=ext_modules(), File "/tmp/pip-install-twazq3g6/javabridge/setup.py", line 137, in ext_modules library_dirs = [os.path.dirname(jvm_so)] File "/usr/local/lib/python3.6/posixpath.py", line 156, in dirname p = os.fspath(p) TypeError: expected str, bytes or os.PathLike object, not NoneType

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-twazq3g6/javabridge/

kancvinu avatar Nov 24 '18 19:11 kancvinu

Is it possible that you haven't installed the JDK? That error is telling me that the Javabridge install script is unable to find it.

LeeKamentsky avatar Nov 26 '18 13:11 LeeKamentsky

Thanks for your response. Java is installed but the JAVA_HOME path was wrongly set. Correcting the JAVA_HOME fixed the issue.

On Mon, Nov 26, 2018, 19:01 Lee Kamentsky <[email protected] wrote:

Is it possible that you haven't installed the JDK? That error is telling me that the Javabridge install script is unable to find it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/LeeKamentsky/python-javabridge/issues/152#issuecomment-441639498, or mute the thread https://github.com/notifications/unsubscribe-auth/AUoQKaubBvzadQ_3WDilJEv4gy-RGwTNks5uy-0ggaJpZM4Yxjrq .

kancvinu avatar Nov 26 '18 13:11 kancvinu

I'm having the same issue. @kancvinu how did you resolve?

$ JAVA_HOME="/usr/lib/jvm/default-java/"                 
$ pip install javabridge
Collecting javabridge
  Using cached https://files.pythonhosted.org/packages/a6/a0/c59bccabed99b1d4ac68166c59c679b375bfca75b78688b52c541b711578/javabridge-1.0.18.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-bihkt4xy/javabridge/setup.py", line 402, in <module>
        ext_modules=ext_modules(),
      File "/tmp/pip-build-bihkt4xy/javabridge/setup.py", line 137, in ext_modules
        library_dirs = [os.path.dirname(jvm_so)]
      File "/home/tyler/lib/anaconda3/lib/python3.6/posixpath.py", line 154, in dirname
        p = os.fspath(p)
    TypeError: expected str, bytes or os.PathLike object, not NoneType
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-bihkt4xy/javabridge/
You are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Edit: turns out openjdk does not work, but Oracle Java 8 does.

https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-18-04

tbenst avatar Dec 13 '18 01:12 tbenst

Is java located @ /usr/lib/jvm/default-java/? If so, can you try export and then install?

$ export JAVA_HOME="/usr/lib/jvm/default-java/"

$ echo ${JAVA_HOME}

$ pip install javabridge

On Thu, Dec 13, 2018 at 6:57 AM tbenst [email protected] wrote:

I'm having the same issue. @kancvinu https://github.com/kancvinu how did you resolve?

$ JAVA_HOME="/usr/lib/jvm/default-java/" $ pip install javabridge Collecting javabridge Using cached https://files.pythonhosted.org/packages/a6/a0/c59bccabed99b1d4ac68166c59c679b375bfca75b78688b52c541b711578/javabridge-1.0.18.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-bihkt4xy/javabridge/setup.py", line 402, in ext_modules=ext_modules(), File "/tmp/pip-build-bihkt4xy/javabridge/setup.py", line 137, in ext_modules library_dirs = [os.path.dirname(jvm_so)] File "/home/tyler/lib/anaconda3/lib/python3.6/posixpath.py", line 154, in dirname p = os.fspath(p) TypeError: expected str, bytes or os.PathLike object, not NoneType

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-bihkt4xy/javabridge/ You are using pip version 9.0.1, however version 18.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LeeKamentsky/python-javabridge/issues/152#issuecomment-446808184, or mute the thread https://github.com/notifications/unsubscribe-auth/AUoQKVb1WdazlqWBCpBpaz2eV40bZ5y5ks5u4a0DgaJpZM4Yxjrq .

kancvinu avatar Dec 13 '18 12:12 kancvinu

thx, yes turns out I needed JAVA_HOME="/usr/lib/jvm/java-8-oracle/"

tbenst avatar Dec 13 '18 20:12 tbenst

Hello all, I use windows, and I have in my sistem configurated JAVA_HOME variable, but pip install javabridge not worked, it always get a error to install jdk 1.6 or newer... After a lot of failured tryes, I finnaly make it work, I maked configure the PATH variable with java directory and it works. I register this here to help others with the same problem. Cheers.

theodorocaliari avatar May 03 '19 03:05 theodorocaliari

Hi Lee, hope things are fine on your side! It would be super great if you could add this recommendation to the install docs (ideally also for CellProfiler). python-javabridge fails to install on a vanilla Ubuntu 16.04 and 18.04 with openjdk-8-jdk, openjdk-11-jdk and default-jdk packages installed. The error message is not very helpful:

Collecting javabridge>=1.0 (from CellProfiler==3.1.8)
  Using cached https://files.pythonhosted.org/packages/a6/a0/c59bccabed99b1d4ac68166c59c679b375bfca75b78688b52c541b711578/javabridge-1.0.18.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /opt/CellProfiler/envs/cellprofiler/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gtmtnzps/javabridge/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gtmtnzps/javabridge/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-gtmtnzps/javabridge/
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-gtmtnzps/javabridge/setup.py", line 402, in <module>
        ext_modules=ext_modules(),
      File "/tmp/pip-install-gtmtnzps/javabridge/setup.py", line 137, in ext_modules
        library_dirs = [os.path.dirname(jvm_so)]
      File "/opt/CellProfiler/envs/cellprofiler/lib/python3.7/posixpath.py", line 156, in dirname
        p = os.fspath(p)
    TypeError: expected str, bytes or os.PathLike object, not NoneType

With some luck the user may guess that Java is not correctly found. Sadly, this requirement is not highlighted from the documentation at https://pythonhosted.org/javabridge/installation.html. Even when setting JAVA_HOME a user may be tempted to set it to the default java path on Ubuntu, i.e. something like

export JAVA_HOME="/usr/lib/jvm/default-java"

However this may default to openjdk-11-jdk which does not ship the required jni.h. The solution for me was to set

export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64"

which then builds and works fine.

emmenlau avatar Oct 07 '19 14:10 emmenlau

There may be a jni.h file in the openjdk-11 Debian package: https://ubuntu.pkgs.org/18.04/ubuntu-main-amd64/openjdk-11-jdk-headless_10.0.1+10-3ubuntu1_amd64.deb.html It looks like it's put in /usr/lib/jvm/java-11-openjdk-amd64/include/jni.h I'd appreciate a patch - I may get to looking at this at some point though.

LeeKamentsky avatar Oct 07 '19 20:10 LeeKamentsky

Hello I'm having trouble installing javabridge in my Raspberry Pi 3B+ (Raspbian Buster). I followed the instructions from the javabridge website and this forum stated above, but to no avail. I also followed the export command but the problem still persists. The error message is shown below and I hope this may be helpful:

` pi@raspberrypi:~ $ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-armhf pi@raspberrypi:~ $ sudo pip3 install javabridge Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting javabridge Using cached https://files.pythonhosted.org/packages/a6/a0/c59bccabed99b1d4ac68166c59c679b375bfca75b78688b52c541b711578/javabridge-1.0.18.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-install-og056ij9/javabridge/setup.py", line 402, in ext_modules=ext_modules(), File "/tmp/pip-install-og056ij9/javabridge/setup.py", line 137, in ext_modules library_dirs = [os.path.dirname(jvm_so)] File "/usr/lib/python3.7/posixpath.py", line 156, in dirname p = os.fspath(p) TypeError: expected str, bytes or os.PathLike object, not NoneType

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-og056ij9/javabridge/ pi@raspberrypi:~ $ ` Hoping for a response, Thank You!

phinjomcent avatar Mar 19 '20 14:03 phinjomcent

I see that this issue is still relevant on Ubuntu 20.04...

emmenlau avatar Sep 02 '21 14:09 emmenlau

Trying to install CellProfiler from pip so it works with my cellpose installation. Getting same javabridge error, I have already set java environment variable on windows 10.

rayhendricks avatar May 17 '22 17:05 rayhendricks

I no longer have control over the project on PyPi, so can't update it there to fix bugs. Please install from Github directly.

LeeKamentsky avatar May 17 '22 17:05 LeeKamentsky

hi, i have same problem. I did set the JAVA_HOME. Although environ returns the path i still run into RuntimeError: Failed to find the Java Development Kit. Please download and install the Oracle JDK 1.6 or later. Java version: jdk-11.0.16.101-hotspot, Win

tP1rx avatar Mar 01 '24 10:03 tP1rx