This problem appeared with the jpyp library, and it gives me the suggestion to add JAVA_HOME to the environment variable And I don't use java

huangapple go评论66阅读模式
英文:

This problem appeared with the jpyp library, and it gives me the suggestion to add JAVA_HOME to the environment variable And I don't use java

问题

import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook

# image path
image_name = 'screenshot.png'
image_path = fr'C:\\Users\\Bouregag Youcef\\Downloads\\Telegram Desktop\\analyses\\{image_name}'

# Export the dataframe to an Excel file
excel_name = 'table2.xlsx'
excel_path = fr'C:\\Users\\Bouregag Youcef\\Downloads\\Telegram Desktop\\analyses\\{excel_name}'

workbook = Workbook(image_path)
workbook.save(excel_path)
jpype.shutdownJVM()

================== ERROR ===================

Traceback (most recent call last):
  File "c:\Users\Bouregag Youcef\Downloads\Telegram Desktop\analyses\jpeg_to_xls.py", line 4, in <module>
    jpype.startJVM()
    ^^^^^^^^^^^^^^^^
  File "C:\Users\Bouregag Youcef\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype\_core.py", line 184, in startJVM
    jvmpath = getDefaultJVMPath()
              ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bouregag Youcef\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype\_jvmfinder.py", line 74, in getDefaultJVMPath
    return finder.get_jvm_path()
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Bouregag Youcef\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype\_jvmfinder.py", line 212, in get_jvm_path
    raise JVMNotFoundException("No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly."

I searched and found some suggestions, among them is to add JAVA_HOME to the environment variable, but I have not used JAVA at all.

英文:

import  jpype     
import  asposecells     
jpype.startJVM() 
from asposecells.api import Workbook

# image path
image_name = &#39;screenshot.png&#39;
image_path = fr&#39;C:\\Users\\Bouregag Youcef\\Downloads\\Telegram Desktop\\analyses\\{image_name}&#39;

# Export the dataframe to an Excel file
excel_name = &#39;table2.xlsx&#39;
excel_path = fr&#39;C:\\Users\\Bouregag Youcef\\Downloads\\Telegram Desktop\\analyses\\{excel_name}&#39; 


workbook = Workbook(image_path)
workbook.save(excel_path)
jpype.shutdownJVM()

================== ERROR ===================

Traceback (most recent call last):
  File &quot;c:\Users\Bouregag Youcef\Downloads\Telegram Desktop\analyses\jpeg_to_xls.py&quot;, line 4, in &lt;module&gt;
    jpype.startJVM()
    ^^^^^^^^^^^^^^^^
  File &quot;C:\Users\Bouregag Youcef\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype\_core.py&quot;, line 184, in startJVM
    jvmpath = getDefaultJVMPath()
              ^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\Bouregag Youcef\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype\_jvmfinder.py&quot;, line 74, in getDefaultJVMPath
    return finder.get_jvm_path()
           ^^^^^^^^^^^^^^^^^^^^^
  File &quot;C:\Users\Bouregag Youcef\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype\_jvmfinder.py&quot;, line 212, in get_jvm_path
    raise JVMNotFoundException(&quot;No JVM shared library file ({0}) &quot;
jpype._jvmfinder.JVMNotFoundException: No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly.

I searched and found some suggestions, among them is to add java_home to environment variable and I do not and have not used it at all JAVA

答案1

得分: 2

这是关于你错误原因的解释:

File &quot;C:\Users\Bouregag Youcef\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype_jvmfinder.py&quot;, line 212, in get_jvm_path raise JVMNotFoundException(&quot;No JVM shared library file ({0}) &quot; jpype._jvmfinder.JVMNotFoundException: No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly.

不管你的脚本中是否直接使用Java - 你导入的某个模块可能需要Java。它尝试查找某种jvm文件,可能引用了JAVA_HOME变量以实现这一目的。看起来在你的环境变量中没有正确设置它。你可以通过在搜索栏中键入“编辑系统环境变量”来检查它并打开它。在我的情况下,它设置为C:\Program Files\Java\jdk-17.0.5.8-hotspot\,其中jdk-17.0.5.8-hotspot是Java安装文件夹。

英文:

This is the explanation what is the reason of your error:

File &quot;C:\Users\Bouregag Youcef\AppData\Local\Programs\Python\Python311\Lib\site-packages\jpype_jvmfinder.py&quot;, line 212, in get_jvm_path raise JVMNotFoundException(&quot;No JVM shared library file ({0}) &quot; jpype._jvmfinder.JVMNotFoundException: No JVM shared library file (jvm.dll) found. Try setting up the JAVA_HOME environment variable properly.

It does not matter that you do not use Java in your script directly - one of your imported modules does though. It tries to find some kind of jvm file and probably refer to JAVA_HOME variable to achieve it. It looks as if it is not set correctly in your Environment Variables. You can check it by typing in search bar Edit the system environment variables and opening it. In my case it is set to C:\Program Files\Java\jdk-17.0.5.8-hotspot\ where jdk-17.0.5.8-hotspot is Java installation folder.

答案2

得分: 2

我通过下载和安装JDK,最后将其添加到名为"JAVA_HOME"的环境变量中,解决了这个问题。

https://www.oracle.com/eg/java/technologies/downloads/#jdk19-windows

英文:

I solved the problem by downloading and installing jdk and finally adding it to environment variable with name "JAVA_HOME"

https://www.oracle.com/eg/java/technologies/downloads/#jdk19-windows

huangapple
  • 本文由 发表于 2023年3月7日 05:33:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75656048.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定