Problems installing python-bioformats (java not found)

Hello, I am new here and looking to work with python-bioformats. I have managed to install python-bioformat, but I am having issues installing python-javabridge, I am getting the error “javac failed: No such file or directory” in terminal (mac) upon installing javabridge (using pip and also via github link). Not even sure where to start with solving this problem. Thank you very much in advance.

1 Like

In terminal if you type echo $JAVA_HOME what all output do you get?
If you then type /usr/libexec/java_home -V that should list all the different versions available.
You can then set one of these available versions using: export JAVA_HOME=/usr/libexec/java_home -v 12` for example if you want version 12

Hi David,

Thank you for your reply. When I write echo $JAVA_HOME I get:

/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home

I have set the version in my nano .zshrc as

export JAVA_HOME=/usr/libexec/java_home

However I am still running into the same issue.

I am now getting the following errors upon pip install python-javabridge

 #  define NULL ((void*)0)
                   ^~~~~~~~~~
    2 warnings and 2 errors generated.
    error: command '/usr/bin/gcc' failed with exit code 

Also, with regards to bioformats - I have bioformats installed however if I try pip install python-bioformats (because I now understand they are different things) I get errors also with regards to building wheels for javabridge and javac not being available.

Thanks for your help again

Do you have the full print out of the errors you are seeing? Does it look similar to the ones reported in Errors Installing on macOS Mojave · Issue #169 · LeeKamentsky/python-javabridge · GitHub or Errors installing on macOS Sierra · Issue #159 · LeeKamentsky/python-javabridge · GitHub?

1 Like

Apologies for not including the full print. I will paste it below.

pip install python-javabridge

gives me…:

Collecting python-javabridge
  Using cached python-javabridge-4.0.0.tar.gz (1.3 MB)
Requirement already satisfied: numpy>=1.18.2 in ./OneDrive - University of Warwick/Mini-Project 1 Steve Royle/NewVE/lib/python3.9/site-packages (from python-javabridge) (1.19.5)
Building wheels for collected packages: python-javabridge
  Building wheel for python-javabridge (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: '/Users/u2056710/OneDrive - University of Warwick/Mini-Project 1 Steve Royle/NewVE/bin/python' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/setup.py'"'"'; __file__='"'"'/private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-wheel-jpp_0ii4
       cwd: /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/
  Complete output (2460 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.9
  creating build/lib.macosx-10.9-x86_64-3.9/javabridge
  copying javabridge/jutil.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge
  copying javabridge/locate.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge
  copying javabridge/__init__.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge
  copying javabridge/wrappers.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge
  copying javabridge/noseplugin.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge
  creating build/lib.macosx-10.9-x86_64-3.9/javabridge/tests
  copying javabridge/tests/__init__.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge/tests
  copying javabridge/tests/test_cpython.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge/tests
  copying javabridge/tests/test_javabridge.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge/tests
  copying javabridge/tests/test_jutil.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge/tests
  copying javabridge/tests/test_wrappers.py -> build/lib.macosx-10.9-x86_64-3.9/javabridge/tests
  creating build/lib.macosx-10.9-x86_64-3.9/javabridge/jars
  copying javabridge/jars/rhino-1.7R4.jar -> build/lib.macosx-10.9-x86_64-3.9/javabridge/jars
  running build_ext

javac -source 8 -target 8 /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java/org/cellprofiler/runnablequeue/RunnableQueue.java
  jar cf /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/build/lib.macosx-10.9-x86_64-3.9/javabridge/jars/runnablequeue.jar -C /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java org/cellprofiler/runnablequeue/RunnableQueue.class -C /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java org/cellprofiler/runnablequeue/RunnableQueue$1.class
  javac -source 8 -target 8 /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java/org/cellprofiler/javabridge/test/RealRect.java
  jar cf /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/build/lib.macosx-10.9-x86_64-3.9/javabridge/jars/test.jar -C /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java org/cellprofiler/javabridge/test/RealRect.class
  javac -source 8 -target 8 /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java/org/cellprofiler/javabridge/CPython.java /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java/org/cellprofiler/javabridge/CPythonInvocationHandler.java
  Note: /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java/org/cellprofiler/javabridge/CPythonInvocationHandler.java uses unchecked or unsafe operations.
  Note: Recompile with -Xlint:unchecked for details.
  jar cf /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/build/lib.macosx-10.9-x86_64-3.9/javabridge/jars/cpython.jar -C /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java org/cellprofiler/javabridge/CPythonInvocationHandler.class -C /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java org/cellprofiler/javabridge/CPython.class -C /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java org/cellprofiler/javabridge/CPython$WrappedException.class -C /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java org/cellprofiler/javabridge/CPython$StackFrame.class -C /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/java org/cellprofiler/javabridge/CPythonInvocationHandler.class
  building 'javabridge._javabridge' extension
  creating build/temp.macosx-10.9-x86_64-3.9
  gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Users/u2056710/OneDrive - University of Warwick/Mini-Project 1 Steve Royle/NewVE/lib/python3.9/site-packages/numpy/core/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home/include/darwin -I/Users/u2056710/OneDrive - University of Warwick/Mini-Project 1 Steve Royle/NewVE/lib/python3.9/site-packages/numpy/core/include -I/Users/u2056710/OneDrive - University of Warwick/Mini-Project 1 Steve Royle/NewVE/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c _javabridge.c -o build/temp.macosx-10.9-x86_64-3.9/_javabridge.o
  In file included from _javabridge.c:4:
  In file included from /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/Python.h:25:
  In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:64:
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:93:16: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
          unsigned char   *_base;
                          ^
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:93:16: note: insert '_Nullable' if the pointer may be null
          unsigned char   *_base;
                          ^
                            _Nullable
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:93:16: note: insert '_Nonnull' if the pointer should never be null
          unsigned char   *_base;
                          ^
                            _Nonnull
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:138:32: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
          int     (* _Nullable _read) (void *, char *, int);

the error is actually much longer - if you want the complete output i am happy to post it, but it is huge.

The errors end with:

 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/_types.h:52:23: note: expanded from macro '__DARWIN_NULL'
    #define __DARWIN_NULL ((void *)0)
                          ^~~~~~~~~~~
    221 warnings and 2 errors generated.
    error: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: '/Users/u2056710/OneDrive - University of Warwick/Mini-Project 1 Steve Royle/NewVE/bin/python' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/setup.py'"'"'; __file__='"'"'/private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-install-b09z0yrt/python-javabridge_acce2e9bf8eb431a8abfcd9b073f535b/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/ct/3j4nw9px7dnf3m686fs99dg40000gp/T/pip-record-xrc09p5p/install-record.txt --single-version-externally-managed --compile --install-headers '/Users/u2056710/OneDrive - University of Warwick/Mini-Project 1 Steve Royle/NewVE/include/site/python3.9/python-javabridge' Check the logs for full command output.

Thanks again for your time and help. Really keen on getting this up and running! :slight_smile:

If you run the command below does it show gcc to be installed?
gcc --version

If not then that may be what is missing, you should be able to install it via:
brew install gcc

Hi David, after some troubleshooting, the only thing that managed to allow the install was the following:

export CFLAGS='-Wno-implicit-function-declaration'`Preformatted text`

As well as setting up a new virtual environment. Thanks for your help!