Error with tabula_py

Hello there.

I run code on streamlit cloud.

uploaded_file = st.file_uploader('PDF file', type='pdf', key='pdf')
df = pd.DataFrame()
if not uploaded_file:'select a PDF file')
elif uploaded_file:
    df = tabula.read_pdf(uploaded_file, lattice=True, pages='1') 

Then a error message had happend.

raise JavaNotFoundError(JAVA_NOT_FOUND_ERROR)

tabula.errors.JavaNotFoundError: `java` command is not found from this Python process.Please ensure Java is installed and PATH is set for `java`

Please tell me how to fix that error.

The error message you’re encountering, JavaNotFoundError: 'java' command is not found from this Python process, indicates that the Java runtime environment (JRE) is not installed or not accessible from your Streamlit Cloud environment. To resolve this issue, you can follow these steps:

  1. Verify Java installation: Check if Java is installed on your Streamlit Cloud environment. You can try running the java -version command in the terminal to see if it returns the Java version. If the command is not recognized, it means Java is not installed.

  2. Install Java: If Java is not installed, you will need to install it. The exact steps may depend on the operating system or package manager used in your Streamlit Cloud environment. For example, if you’re using Ubuntu, you can install Java by running the following command:

    sudo apt-get install default-jre

    If you have more specific requirements for Java, such as a particular version, make sure to install the appropriate package.

  3. Configure Java PATH: After installing Java, ensure that the Java executable (java) is added to the system’s PATH environment variable. The PATH should point to the directory where the java executable is located. This allows the Python process to find and execute the Java commands.

  4. Restart the Streamlit app: Once you have installed Java and configured the PATH, restart your Streamlit app in the Streamlit Cloud environment. This ensures that the changes take effect.

By following these steps, you should be able to resolve the JavaNotFoundError and use tabula-py in your Streamlit app on the Streamlit Cloud platform to extract data from PDF files. If you continue to encounter issues, it may be helpful to reach out to the Streamlit Cloud support team for further assistance.

Thank you for your reply.
I verify java installation. ok.
My code can run on my local host.
But it can’t run on streamlit cloud.

I hear need to make packges.txt.
Please tell me how to make packages.txt.

1 Like

I wrote openjdk-17-jre in package.txt.
app worked!
Thank you.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.