【问题标题】:Difficulties starting JVM in Python using jpype使用 jpype 在 Python 中启动 JVM 的困难
【发布时间】:2018-05-08 05:35:00
【问题描述】:

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

我正在运行 32 位 Python 3.6.5 和 32 位 Oracle Java 1.8 更新 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
>>>

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

【问题讨论】:

标签: python jvm dllimport jpype


【解决方案1】:

在挖掘我一直在研究的 3 个 Windows 系统之间的差异(2 个工作和这个不工作)时,我发现 Microsoft Visual C++ 2010 Redistributable Package (x86) 已安装在前 2 个系统上,但不是表现出这种行为的那个.

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

【讨论】:

    猜你喜欢
    • 2017-11-26
    • 2019-09-20
    • 2011-12-11
    • 1970-01-01
    • 2016-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多