-
Notifications
You must be signed in to change notification settings - Fork 76
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
OSError: [WinError 193] JVM DLL not found #49
Comments
I don't know how to fix this, and yes it is strange. To investigate, you could start by running this little script: import jpype
jpype.startJVM('C:/Program Files/COMSOL/COMSOL56/Multiphysics/java/win64/jre/bin/server/jvm.dll') You may have to change the path if you use a different Comsol version or installed it in a custom location. Does that script produce the same error? |
Hi, |
Okay, then the answer is, unfortunately, that nobody knows how to fix this. At least up until now. Though maybe you want to look into this a little more. This is a rare error that has been encountered before, but cannot be reliably reproduced by other people. As you can see, this has nothing to do with MPh. The script above only uses JPype to try and start Comsol's Java VM, which fails. The JPype project provides some instructions for debugging JVM start-up issues on Windows. Near the very end, it has this to say:
That's your error code right there: 193. But there is no known solution. A similar issue has been reported, jpype-project/jpype#777, also unresolved, and there the Windows error codes is 126, which, as you point out, would make a little more sense if the actual Java DLL was not found. But then again, that isn't truly the issue since it's right there and should be found. So this all points to a possible issue with the DLLs that the Java DLL itself depends on. All I can offer here is show what the Java VM's dependencies look like on a system where everything works fine. This is Windows 10 and Comsol 5.6 is installed in its default location. None of Comsol's folders are on the search path (i.e., listed in the Following JPype's debugging instructions, we need Visual Studio to get the $ "C:\programs\Visual Studio\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.3
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
$ dumpbin /dependents "C:\Program Files\COMSOL\COMSOL56\Multiphysics\java\win64\jre\bin\server\jvm.dll"
Microsoft (R) COFF/PE Dumper Version 14.29.30133.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file C:\Program Files\COMSOL\COMSOL56\Multiphysics\java\win64\jre\bin\server\jvm.dll
File Type: DLL
Image has the following dependencies:
KERNEL32.dll
USER32.dll
ADVAPI32.dll
WSOCK32.dll
WINMM.dll
VERSION.dll
PSAPI.DLL
MSVCR120.dll
Summary
76000 .data
4C000 .pdata
1C4000 .rdata
2E000 .reloc
1000 .rsrc
5B0000 .text All of these DLLs are in the Windows folder. For example, we can check: $ where advapi32.dll
C:\Windows\System32\advapi32.dll Though $ cd "C:\Program Files\COMSOL\COMSOL56\Multiphysics\java\win64\jre\bin"
$ where msvcr120.dll
C:\Program Files\COMSOL\COMSOL56\Multiphysics\java\win64\jre\bin\msvcr120.dll
C:\Windows\System32\msvcr120.dll
$ python
Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jpype
>>> jpype.startJVM('./server/jvm.dll')
>>> jpype.isJVMStarted()
True Also according to the debug instructions, I compiled and ran $ git clone https://github.com/jpype-project/jpype.git --depth 1
Cloning into 'jpype'...
remote: Enumerating objects: 557, done.
remote: Counting objects: 100% (557/557), done.
remote: Compressing objects: 100% (451/451), done.R
remote: Total 557 (delta 141), reused 218 (delta 54), pack-reused 0
Receiving objects: 100% (557/557), 809.88 KiB | 6.86 MiB/s, done.
Resolving deltas: 100% (141/141), done.
$ cd jpype\project\debug\windows
$ "C:\programs\Visual Studio\VC\Auxiliary\Build\vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.3
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
$ cl testJVM.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30133 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
testJVM.cpp
Microsoft (R) Incremental Linker Version 14.29.30133.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:testJVM.exe
testJVM.obj
$ testJVM "C:\Program Files\COMSOL\COMSOL56\Multiphysics\java\win64\jre\bin\server\jvm.dll"
Check paths
SystemDirectory: C:\Windows\system32
WindowsDirectory: C:\Windows
Load library
Load entry points
Entry point found 0000000071518010
Pack JVM arguments
Num options: 0
Create JVM
Create Java resources
Destroy JVM
Unload library
Success So if you see anything suspicious when you do the same on your system, that might be a clue. Otherwise, well, nobody has a solution, so you're on your own. But if you solve this, please report back, either here or even on the JPype issue I linked. |
Thanks for your help. |
I have found a way to start the JVM.
Since I'm not very familiar with how to include the path of the
|
Somehow I wasn't notified of your comment and probably marked the issue as "can't fix" a little too soon. What happens if you just clear the import mph
import os
os.environ['PATH'] = ''
client = mph.start() Or if you prepend the import mph
import os
jre = r'C:\Program Files\COMSOL\COMSOL56\Multiphysics\java\win64\jre\bin'
os.environ['PATH'] = jre + os.pathsep + os.environ['PATH']
client = mph.start() If the latter works, then that's actually fixable in MPh library code. |
Hey, come back. @Miso-1 |
Sorry, had a busy week. First solution changes the error from If i add |
Okay, perfect. Because that, I can fix. I just have to shuffle some things around. I'll ping you again when the new release is out, in a week or so, and then it'll (hopefully) work out of the box on your end. To summarize (because this might help other JPype users)… What happened here is that the 64-bit Java DLL tried to import one of its dependencies, which ended up being a 32-bit DLL because of an unusual search-path order, and mixing 64-bit and 32-bit will fail. Dynamic linking is a blessing (for other reasons) and a curse (for precisely this one). If we manipulate the search path (only inside our very own Python process) prior to loading the Java VM, then it should work out. |
Should be fixed in MPh 1.1.0, released today. @Miso-1 When you get a chance, please confirm that |
The new release fixed the problem for me. |
Hi,
Im trying to get a Simulation via Python in Comsol running.
My issue is, that the command "mph.start()" produces the error message:
"OSError: [WinError 193] JVM DLL not found"
Strange things:
Maybe anybody knows how to fix this?
The text was updated successfully, but these errors were encountered: