python-javabridge
python-javabridge copied to clipboard
JVMNotFoundError NameError on pip install
While trying to pip install --upgrade
from 1.03 to 1.0.9, I get the following error:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "c:\users\develo~1\appdata\local\temp\pip_build_Developer\javabridge\setup.py", line 238, in <module>
ext_modules=ext_modules(),
File "c:\users\develo~1\appdata\local\temp\pip_build_Developer\javabridge\setup.py", line 58, in ext_modules
raise JVMNotFoundError()
NameError: global name 'JVMNotFoundError' is not defined
This occurs in the error handling code. The class JVMNotFound should probably be moved from jutil.py to locate.py, then imported by jutil.py.
But that doesn't fix the reason the error-handling code was invoked in the first place. On Windows, it uses the %JAVA_HOME% environment variable if that is set, but otherwise it goes through the following to look up in the registry where Java is:
import _winreg
java_key_path = 'SOFTWARE\\JavaSoft\\Java Runtime Environment'
looking_for = java_key_path
try:
kjava = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, java_key_path)
looking_for = java_key_path + "\\CurrentVersion"
kjava_values = dict([_winreg.EnumValue(kjava, i)[:2]
for i in range(_winreg.QueryInfoKey(kjava)[1])]
current_version = kjava_values['CurrentVersion']
looking_for = java_key_path + '\\' + current_version
kjava_current = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
looking_for)
kjava_current_values = dict([_winreg.EnumValue(kjava_current, i)[:2]
for i in range(_winreg.QueryInfoKey(kja
return kjava_current_values['JavaHome']
except:
logger.error("Failed to find registry entry: %s\n" %looking_for,
exc_info=True)
return None
Can you please try to work through that (and either run it line by line or looking in your registry manually) and see if you can determine why it doesn't find it? (Java is installed, right?)
@braymp are you able to solve this ? Please comment if you have found a hack around. @LeeKamentsky any suggestions, I too am getting the same error.
Rupav, it looks to me from the traceback in https://github.com/HelikarLab/candis/issues/9 that you do not have the Java runtime environment installed on your Windows machine. Can you check that Java is installed on your machine (and post the version if it is)?
Its 9.0.4 version @LeeKamentsky
I'm wondering why you had to set PATH to the bin directory of the JDK. It sounds like the standard installation was not done maybe? That would account for the missing registry key.
You could try setting the JAVA_HOME environment variable to the path to your JDK installation - that might work, even though it's not the right way to do it.
While handling the issue, I found a suggestion on stackoverflow to add PATH to bin directory to JDK. Now that even I have removed it from system variables' PATH. java --version
is still showing up (So I guess you were right, it was not needed at all to set the path manually)
@LeeKamentsky I am able to solve this error, big thanks for your help through discussion :) . What I did (as you suggested),
in environment variable, I added variable named JAVA_HOME
with value set to java/jdk directory.
then added this To system PATH.
Unfortunately pip install javabridge
is producing now a new error:
Can you try setting the JDK_HOME environment variable to the root of your JDK? I think that would be the work-around.
I will try it in morning sir (it's 2 AM in India ) and update you ASAP. But isn't JAVA_HOME pointing to the same value (root of JDK). JDK_HOME env. variable to be assigned the same value then?
In the last screenshot, I have captured value of JAVA_HOME
environment variable too. Please see for reference.
Looking at the code, I can see you need both the JDK_HOME and JAVA_HOME. I'll talk to you tomorrow, good luck
C:\Users\MARK>pip install javabridge
Collecting javabridge
Using cached javabridge-1.0.15.tar.gz
Requirement already satisfied: numpy in c:\users\mark\anaconda3\lib\site-packages (from javabridge)
Building wheels for collected packages: javabridge
Running setup.py bdist_wheel for javabridge ... error
Complete output from command C:\Users\MARK\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\MARK\\AppData\\Local\\Temp\\pip-build-0oggsseg\\javabridge\\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 C:\Users\MARK\AppData\Local\Temp\tmph9w1ufzhpip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\javabridge
copying javabridge\jutil.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\locate.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\noseplugin.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\wrappers.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\_version.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\__init__.py -> build\lib.win-amd64-3.6\javabridge
creating build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\test_cpython.py -> build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\test_javabridge.py -> build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\test_jutil.py -> build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\test_wrappers.py -> build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\__init__.py -> build\lib.win-amd64-3.6\javabridge\tests
creating build\lib.win-amd64-3.6\javabridge\jars
copying javabridge\jars\cpython.jar -> build\lib.win-amd64-3.6\javabridge\jars
copying javabridge\jars\rhino-1.7R4.jar -> build\lib.win-amd64-3.6\javabridge\jars
copying javabridge\jars\runnablequeue.jar -> build\lib.win-amd64-3.6\javabridge\jars
copying javabridge\jars\test.jar -> build\lib.win-amd64-3.6\javabridge\jars
running build_ext
C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\runnablequeue\RunnableQueue.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
4 warnings
C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\test\RealRect.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
4 warnings
C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPython.java C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPythonInvocationHandler.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Note: C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPythonInvocationHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 warnings
building 'javabridge._javabridge' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
----------------------------------------
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
Complete output from command C:\Users\MARK\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\MARK\\AppData\\Local\\Temp\\pip-build-0oggsseg\\javabridge\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\MARK\AppData\Local\Temp\pip-43a4pfba-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\javabridge
copying javabridge\jutil.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\locate.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\noseplugin.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\wrappers.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\_version.py -> build\lib.win-amd64-3.6\javabridge
copying javabridge\__init__.py -> build\lib.win-amd64-3.6\javabridge
creating build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\test_cpython.py -> build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\test_javabridge.py -> build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\test_jutil.py -> build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\test_wrappers.py -> build\lib.win-amd64-3.6\javabridge\tests
copying javabridge\tests\__init__.py -> build\lib.win-amd64-3.6\javabridge\tests
creating build\lib.win-amd64-3.6\javabridge\jars
copying javabridge\jars\cpython.jar -> build\lib.win-amd64-3.6\javabridge\jars
copying javabridge\jars\rhino-1.7R4.jar -> build\lib.win-amd64-3.6\javabridge\jars
copying javabridge\jars\runnablequeue.jar -> build\lib.win-amd64-3.6\javabridge\jars
copying javabridge\jars\test.jar -> build\lib.win-amd64-3.6\javabridge\jars
running build_ext
C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\runnablequeue\RunnableQueue.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
4 warnings
C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\test\RealRect.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
4 warnings
C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPython.java C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPythonInvocationHandler.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Note: C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPythonInvocationHandler.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 warnings
building 'javabridge._javabridge' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
----------------------------------------
Command "C:\Users\MARK\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\MARK\\AppData\\Local\\Temp\\pip-build-0oggsseg\\javabridge\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\MARK\AppData\Local\Temp\pip-43a4pfba-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\
This is what came up after setting JDK_HOME env. variable too.
OK - that one is pretty clear. You need to install the free Visual C++ tools as described in the error message:
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
On Thu, Feb 15, 2018 at 10:02 PM, rupav jain [email protected] wrote:
C:\Users\MARK>pip install javabridge Collecting javabridge Using cached javabridge-1.0.15.tar.gz Requirement already satisfied: numpy in c:\users\mark\anaconda3\lib\site-packages (from javabridge) Building wheels for collected packages: javabridge Running setup.py bdist_wheel for javabridge ... error Complete output from command C:\Users\MARK\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\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 C:\Users\MARK\AppData\Local\Temp\tmph9w1ufzhpip-wheel- --python-tag cp36: running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\javabridge copying javabridge\jutil.py -> build\lib.win-amd64-3.6\javabridge copying javabridge\locate.py -> build\lib.win-amd64-3.6\javabridge copying javabridge\noseplugin.py -> build\lib.win-amd64-3.6\javabridge copying javabridge\wrappers.py -> build\lib.win-amd64-3.6\javabridge copying javabridge_version.py -> build\lib.win-amd64-3.6\javabridge copying javabridge_init_.py -> build\lib.win-amd64-3.6\javabridge creating build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests\test_cpython.py -> build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests\test_javabridge.py -> build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests\test_jutil.py -> build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests\test_wrappers.py -> build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests_init_.py -> build\lib.win-amd64-3.6\javabridge\tests creating build\lib.win-amd64-3.6\javabridge\jars copying javabridge\jars\cpython.jar -> build\lib.win-amd64-3.6\javabridge\jars copying javabridge\jars\rhino-1.7R4.jar -> build\lib.win-amd64-3.6\javabridge\jars copying javabridge\jars\runnablequeue.jar -> build\lib.win-amd64-3.6\javabridge\jars copying javabridge\jars\test.jar -> build\lib.win-amd64-3.6\javabridge\jars running build_ext C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\runnablequeue\RunnableQueue.java warning: [options] bootstrap class path not set in conjunction with -source 1.6 warning: [options] source value 1.6 is obsolete and will be removed in a future release warning: [options] target value 1.6 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. 4 warnings C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\test\RealRect.java warning: [options] bootstrap class path not set in conjunction with -source 1.6 warning: [options] source value 1.6 is obsolete and will be removed in a future release warning: [options] target value 1.6 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. 4 warnings C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPython.java C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPythonInvocationHandler.java warning: [options] bootstrap class path not set in conjunction with -source 1.6 warning: [options] source value 1.6 is obsolete and will be removed in a future release warning: [options] target value 1.6 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. Note: C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPythonInvocationHandler.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 warnings building 'javabridge._javabridge' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
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 Complete output from command C:\Users\MARK\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\MARK\AppData\Local\Temp\pip-43a4pfba-record\install-record.txt --single-version-externally-managed --compile: running install running build running build_py creating build creating build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\javabridge copying javabridge\jutil.py -> build\lib.win-amd64-3.6\javabridge copying javabridge\locate.py -> build\lib.win-amd64-3.6\javabridge copying javabridge\noseplugin.py -> build\lib.win-amd64-3.6\javabridge copying javabridge\wrappers.py -> build\lib.win-amd64-3.6\javabridge copying javabridge_version.py -> build\lib.win-amd64-3.6\javabridge copying javabridge_init_.py -> build\lib.win-amd64-3.6\javabridge creating build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests\test_cpython.py -> build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests\test_javabridge.py -> build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests\test_jutil.py -> build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests\test_wrappers.py -> build\lib.win-amd64-3.6\javabridge\tests copying javabridge\tests_init_.py -> build\lib.win-amd64-3.6\javabridge\tests creating build\lib.win-amd64-3.6\javabridge\jars copying javabridge\jars\cpython.jar -> build\lib.win-amd64-3.6\javabridge\jars copying javabridge\jars\rhino-1.7R4.jar -> build\lib.win-amd64-3.6\javabridge\jars copying javabridge\jars\runnablequeue.jar -> build\lib.win-amd64-3.6\javabridge\jars copying javabridge\jars\test.jar -> build\lib.win-amd64-3.6\javabridge\jars running build_ext C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\runnablequeue\RunnableQueue.java warning: [options] bootstrap class path not set in conjunction with -source 1.6 warning: [options] source value 1.6 is obsolete and will be removed in a future release warning: [options] target value 1.6 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. 4 warnings C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\test\RealRect.java warning: [options] bootstrap class path not set in conjunction with -source 1.6 warning: [options] source value 1.6 is obsolete and will be removed in a future release warning: [options] target value 1.6 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. 4 warnings C:\Program Files\Java\jdk-9.0.4\bin\javac.exe -source 6 -target 6 C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPython.java C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPythonInvocationHandler.java warning: [options] bootstrap class path not set in conjunction with -source 1.6 warning: [options] source value 1.6 is obsolete and will be removed in a future release warning: [options] target value 1.6 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. Note: C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\java\org\cellprofiler\javabridge\CPythonInvocationHandler.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 warnings building 'javabridge._javabridge' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
----------------------------------------
Command "C:\Users\MARK\Anaconda3\python.exe -u -c "import setuptools, tokenize;file='C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\MARK\AppData\Local\Temp\pip-43a4pfba-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\MARK\AppData\Local\Temp\pip-build-0oggsseg\javabridge\
This is what came up after setting JDK_HOME env. variable too.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LeeKamentsky/python-javabridge/issues/34#issuecomment-366132321, or mute the thread https://github.com/notifications/unsubscribe-auth/AAoT9aQHGmx1coEoGtMUFdVsSdimbaUcks5tVO_MgaJpZM4C5JIP .
@rupav Can u tell me how did u end up solving this error?