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

ImportError: DLL load failed while importing _jpype #1167

Open
panc-test opened this issue Dec 27, 2023 · 3 comments
Open

ImportError: DLL load failed while importing _jpype #1167

panc-test opened this issue Dec 27, 2023 · 3 comments

Comments

@panc-test
Copy link

panc-test commented Dec 27, 2023

Traceback (most recent call last):
File "C:/Users/057776/PycharmProjects/funds-app-mock/utils/encrypt.py", line 9, in
import jpype
File "C:\Users\057776\PycharmProjects\funds-app-mock\venv\lib\site-packages\jpype_init_.py", line 18, in
import _jpype
ImportError: DLL load failed while importing _jpype: 找不到指定的模块。

version = "1.5.0"
JPype1-1.5.0-cp38-cp38-win_amd64.whl
wind10 ,64

(venv) C:\Users\057776\PycharmProjects\funds-app-mock>pip install JPype1
Requirement already satisfied: JPype1 in c:\users\057776\pycharmprojects\funds-app-mock\venv\lib\site-packages (1.5.0)
Requirement already satisfied: packaging in c:\users\057776\pycharmprojects\funds-app-mock\venv\lib\site-packages (from JPype1) (23.2)

@marscher
Copy link
Member

It'd be great to have the error message in English. Setting the locale in your operating system or setting a shell variable should do the trick

@ryanmkurtz
Copy link
Contributor

ryanmkurtz commented Jul 12, 2024

I'm seeing basically the same thing in a Windows 11 sandbox with the standard python.org 3.12.4 installed:

C:\Users\WDAGUtilityAccount>py
Python 3.12.4 (tags/v3.12.4:8e8a4ba, Jun  6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jpype
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python312\Lib\site-packages\jpype\__init__.py", line 18, in <module>
    import _jpype
ImportError: DLL load failed while importing _jpype: The specified module could not be found.
>>>

@astrelsky
Copy link
Contributor

astrelsky commented Jul 13, 2024

I'm seeing basically the same thing in a Windows 11 sandbox with the standard python.org 3.12.4 installed:

C:\Users\WDAGUtilityAccount>py
Python 3.12.4 (tags/v3.12.4:8e8a4ba, Jun  6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jpype
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\WDAGUtilityAccount\AppData\Local\Programs\Python\Python312\Lib\site-packages\jpype\__init__.py", line 18, in <module>
    import _jpype
ImportError: DLL load failed while importing _jpype: The specified module could not be found.
>>>

I don't know why, but it's not finding msvcp140.dll even though it comes with Java and is added to the system path by default when installing Java. Copying C:\Program Files\Eclipse Adoptium\jdk-22.0.1.8-hotspot\bin\msvcp140.dll to C:\Windows\System32\ does fix it.

This really doesn't make any sense. The msvcp140.dll can be found and loaded using ctypes.util.find_library and ctypes.WinDLL, and then importing jpype will work just fine after that. This almost looks like a python bug, but it could be some weird windows configuration thing.

The "correct" solution to recommend is probably to install the Latest Microsoft Visual C++ Redistributable Version but it really shouldn't be necessary since it comes with Java and is in the system path already.

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

4 participants