uploaded_file = st.file_uploader('PDF file', type='pdf', key='pdf')
df = pd.DataFrame()
if not uploaded_file:
st.info('select a PDF file')
st.stop()
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`
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:
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.
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.
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.
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.