gpt4 book ai didi

python - 使用 jpype 在 Python 中启动 JVM 的困难

转载 作者:太空宇宙 更新时间:2023-11-03 15:45:23 28 4
gpt4 key购买 nike

我最近一直在使用 jpype 与一些使用 python 的 java 代码集成,并且没有遇到任何实际问题。我现在正尝试在新系统上设置我的堆栈,但遇到了困难。

我正在运行 32 位 Python 3.6.5 和 32 位 oracle Java 1.8 update 171。Python 和 jpype 已使用 conda 安装(conda create -n venv -c conda-forge python jpype1 arrow)和

jpype.getDefaultJVMPath() 返回预期路径(C:\Program Files (x86)\Java\jre1.8.0_171\bin\client\jvm.dll ),但是会引发异常,指出它找不到该模块。下面是 python 控制台的输出。

Python 3.6.5 | packaged by conda-forge | (default, Apr  6 2018, 16:13:16) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jpype
>>> import os
>>> jpype.__version__
'0.6.3'
>>> jvm_path=jpype.getDefaultJVMPath()
>>> jvm_path
'C:\\Program Files (x86)\\Java\\jre1.8.0_171\\bin\\client\\jvm.dll'
>>> os.path.exists(jvm_path)
True
>>> jpype.startJVM(jvm_path)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\conda\conda\envs\venv\lib\site-packages\jpype\_core.py", line 70, in startJVM
_jpype.startup(jvm, tuple(args), True)
RuntimeError: Unable to load DLL [C:\Program Files (x86)\Java\jre1.8.0_171\bin\client\jvm.dll], error = The specified module could not be found.
at native\common\include\jp_platform_win32.h:58
>>>

我在这里遗漏了什么和/或做错了什么?

最佳答案

在挖掘我一直在研究的 3 个 Windows 系统之间的差异时(2 个工作,这个不工作)我发现 Microsoft Visual C++ 2010 Redistributable Package (x86)已安装在前 2 个系统上,但没有安装在显示此行为的系统上。

安装 C++ 可再发行组件立即纠正了该问题。

关于python - 使用 jpype 在 Python 中启动 JVM 的困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50226497/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com