2

Trying to explore using Tabula in python on a PDF in Visual Studio code on MacOS.

import pandas as pd
import tabula
dfs = tabula.read_pdf("/Users/TEST.pdf", pages = 1)
len(dfs)

When I run the code however I get the following error:

FileNotFoundError: [Errno 2] JVM DLL not found: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/lib/jli/libjli.dylib

enter image description here

I have installed Java via home-brew, and via a pkg all apparently successful and can run a simple java program in visual studio code just fine. So it is installed, but I don't really know how to solve the above error despite a few attempts.

enter image description here

I am really new to python and installing packages so if you think you can answer, please walk me through like I'm 5 years old.

UPDATE:

import os

# Set the JAVA_HOME environment variable to the Java installation directory
os.environ["JAVA_HOME"] = "/opt/homebrew/opt/openjdk/libexec/openjdk.jdk"

import pandas as pd
import tabula
dfs = tabula.read_pdf("/Users/NickCoding/Desktop/TEST.pdf", pages = 1)
len(dfs)

This allows the code to work, however I feel that this is a botched solution.

How do I get it to work in the virtual environment?

3
  • 1
    Follow this answer to set the environment variable JAVA_HOME for your system
    – JialeDu
    Commented Sep 18, 2023 at 8:19
  • Any updates here?
    – JialeDu
    Commented Oct 5, 2023 at 1:24
  • Latest update I offered as a edit to my question though didnt feel it was good enough as an answer. Will look into the linked answer you hav provided.
    – Nick
    Commented Oct 5, 2023 at 12:50

1 Answer 1

1

I faced the same issue and found a solution.

  1. Install Java Run Time
  2. Install JDK https://www.oracle.com/java/technologies/downloads/#jdk22-mac
  3. export JAVA HOME To export JAVA_HOME=/usr/libexec/java_home -v 14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.