简体   繁体   中英

Python using Tabula / Java unsupported ClassVersion?

i try to use the tabula-module with python and have this code:

import tabula
file = "input.pdf"
tables = tabula.read_pdf(file, pages = "all", multiple_tables = True)

When i try to run this code on windows i get this error:

$ python exampleTabula.py
Error from tabula-java:
java.lang.UnsupportedClassVersionError: technology/tabula/CommandLineApp : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Exception in thread "main"

Traceback (most recent call last):
  File "C:\DEV\Python-Diverses\PDFExtract\exampleTabula.py", line 3, in <module>
    tables = tabula.read_pdf(file, pages = "all", multiple_tables = True)
  File "C:\DEV\.venv\Normal\lib\site-packages\tabula\io.py", line 322, in read_pdf
    output = _run(java_options, kwargs, path, encoding)
  File "C:\DEV\.venv\Normal\lib\site-packages\tabula\io.py", line 80, in _run
    result = subprocess.run(
  File "C:\Users\WRSPOL\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 528, in run
subprocess.CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', '-jar', 'C:\\DEV\\.venv\\Normal\\lib\\site-packages\\tabula\\tabula-1.0.5-jar-with-dependencies.jar', '--pages', 'all', '--guess', '--format', 'JSON', 'foo.pdf']' returned non-zero exit status 1. 

I checked the java-installation an get this infos:

$ which java
/c/Windows/system32/java

and

$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

What i have to do to use tabula on this configuration?

As per https://pypi.org/project/tabula-py/ documentation of Tabula-py, I guess you need Java 8+. And java version "1.7.0_80" is Java 7 I guess.

Kindly try to update Java version to 8+ and try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM