Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip3 install javabridge error #194

Open
CristianR90 opened this issue Aug 11, 2021 · 3 comments
Open

pip3 install javabridge error #194

CristianR90 opened this issue Aug 11, 2021 · 3 comments

Comments

@CristianR90
Copy link

CristianR90 commented Aug 11, 2021

I tried all method in this issues list, but not get success.
JDK: 14.0.2
Numpy: 1.21.1
Gcc installed
Python: 3.9.6

Collecting javabridge
  Using cached javabridge-1.0.19.tar.gz (1.3 MB)
Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from javabridge) (1.21.1)
Building wheels for collected packages: javabridge
  Building wheel for javabridge (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/setup.py'"'"'; __file__='"'"'/private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-wheel-48o8r6vt
       cwd: /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/
  Complete output (44 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/_version.py -> 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
  copying javabridge/jars/runnablequeue.jar -> build/lib.macosx-10.9-x86_64-3.9/javabridge/jars
  copying javabridge/jars/cpython.jar -> build/lib.macosx-10.9-x86_64-3.9/javabridge/jars
  copying javabridge/jars/test.jar -> build/lib.macosx-10.9-x86_64-3.9/javabridge/jars
  running build_ext
  javac /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/runnablequeue/RunnableQueue.java
  javac /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/javabridge/test/RealRect.java
  javac /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/javabridge/CPython.java /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/javabridge/CPythonInvocationHandler.java
  Note: /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/javabridge/CPythonInvocationHandler.java uses unchecked or unsafe operations.
  Note: Recompile with -Xlint:unchecked for details.
  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/System/Library/Frameworks/JavaVM.Framework/Headers -I/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/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:598:
  In file included from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/arrayobject.h:4:
  In file included from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
  In file included from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/ndarraytypes.h:1969:
  /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with "          "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
  #warning "Using deprecated NumPy API, disable it with " \
   ^
  _javabridge.c:600:10: fatal error: 'jni.h' file not found
  #include "jni.h"
           ^~~~~~~
  1 warning and 1 error generated.
  error: command '/usr/bin/gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for javabridge
  Running setup.py clean for javabridge
Failed to build javabridge
Installing collected packages: javabridge
    Running setup.py install for javabridge ... error
    ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/setup.py'"'"'; __file__='"'"'/private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-record-r_qzhtw5/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/javabridge
         cwd: /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/
    Complete output (44 lines):
    running install
    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/_version.py -> 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
    copying javabridge/jars/runnablequeue.jar -> build/lib.macosx-10.9-x86_64-3.9/javabridge/jars
    copying javabridge/jars/cpython.jar -> build/lib.macosx-10.9-x86_64-3.9/javabridge/jars
    copying javabridge/jars/test.jar -> build/lib.macosx-10.9-x86_64-3.9/javabridge/jars
    running build_ext
    javac /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/runnablequeue/RunnableQueue.java
    javac /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/javabridge/test/RealRect.java
    javac /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/javabridge/CPython.java /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/javabridge/CPythonInvocationHandler.java
    Note: /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/java/org/cellprofiler/javabridge/CPythonInvocationHandler.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    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/System/Library/Frameworks/JavaVM.Framework/Headers -I/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/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:598:
    In file included from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/arrayobject.h:4:
    In file included from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
    In file included from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/ndarraytypes.h:1969:
    /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with "          "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
    #warning "Using deprecated NumPy API, disable it with " \
     ^
    _javabridge.c:600:10: fatal error: 'jni.h' file not found
    #include "jni.h"
             ^~~~~~~
    1 warning and 1 error generated.
    error: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/setup.py'"'"'; __file__='"'"'/private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-install-4zi7fkj4/javabridge_d288540d594d4dc29831313208076cef/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/lw/yf0yk_7d53bgfb89t8_j2c8h0000gn/T/pip-record-r_qzhtw5/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/javabridge Check the logs for full command output.
@LeeKamentsky
Copy link
Owner

This looks like a problem where the include file, "jni.h", is not being found. You could find the directory that contains jni.h and set the environment variable, JAVA_HOME, to the parent directory of that before doing the pip install. This should be somewhere within you JDK. Also, there have been some updates since the last release to pypi and you might try:

pip install https://github.com/LeeKamentsky/python-javabridge/archive/master.zip#egg=python-javabridge

instead of pip install javabridge

@skypea
Copy link

skypea commented Dec 1, 2021

Hi,

while running (on Mac, python 3.7)

 pip install https://github.com/LeeKamentsky/python-javabridge/archive/master.zip#egg=python-javabridge

I got

  WARNING: Generating metadata for package python-javabridge produced metadata for project name javabridge. Fix your #egg=python-javabridge fragments.
WARNING: Discarding https://github.com/LeeKamentsky/python-javabridge/archive/master.zip#egg=python-javabridge. Requested javabridge from https://github.com/LeeKamentsky/python-javabridge/archive/master.zip#egg=python-javabridge has inconsistent name: filename has 'python-javabridge', but metadata has 'javabridge'
ERROR: Could not find a version that satisfies the requirement python-javabridge (unavailable) (from versions: 4.0.0, 4.0.1, 4.0.2, 4.0.3)
ERROR: No matching distribution found for python-javabridge (unavailable)

On the other hand,

pip install https://github.com/LeeKamentsky/python-javabridge/archive/master.zip#egg=javabridge

gives

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pycausal 1.2.1 requires javabridge>=1.0.11, but you have javabridge 0.0.0 which is incompatible.
Successfully installed javabridge-0.0.0

Now pip list gives javabridge version 0.0.0. Is this correct?

This looks like a problem where the include file, "jni.h", is not being found. You could find the directory that contains jni.h and set the environment variable, JAVA_HOME, to the parent directory of that before doing the pip install. This should be somewhere within you JDK. Also, there have been some updates since the last release to pypi and you might try:

pip install https://github.com/LeeKamentsky/python-javabridge/archive/master.zip#egg=python-javabridge

instead of pip install javabridge

@LeeKamentsky
Copy link
Owner

I've replicated this on Ubuntu with a virtual environment. The problem is that it tries to pick up the version from a Github clone. I then tried:

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

and when I did pip freeze | grep javabridge I got a version of javabridge==1.0.19.post6+g8aae765.

My guess is that git+https does a git clone under the hood which allows git describe (see https://github.com/LeeKamentsky/python-javabridge/blob/master/setup.py#L352) to work whereas https gets a zip file and doesn't work.

Hope this helps. Please close if it works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants