I am new to unix & cloud not from IT background and not sure how to install Java manually on cloud. I am trying to install Java on streamlit to be able to use Pyspark.
I have tried below code but not sure how to install using downloaded .rpm file with python.
import streamlit as st
import pandas as pd
import os
import sys
import wget
# import tarfile
import platform
1. Download Java
# for linux from: https://crunchify.com/where-is-java-installed-on-my-mac-osx-system/
f = wget.download("https://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.rpm")
st.write(" Java Downloaded")
Java Downloaded
2. Cross check Platform
st.write("Checking platform: ",platform.system())
Checking platform: Linux
3. Checking Directories & files
st.write("Current Directory: ",os.getcwd())
st.write("Directory list: ",os.listdir())
Current Directory: /mount/src/os_explore
Directory list:
[ 0:"requirements.txt" 1:"app.py" 2:"README.md" 3:".git" 4:"jdk-11.0.2_linux-x64_bin.rpm" 5:"packages.txt" 6:".streamlit" ]
4. Installing using .rpm file
# from: https://stackoverflow.com/questions/49484772/install-rpm-or-msi-file-through-python-script
import rpm
import subprocess
package_path = '/mount/src/os_explore/jdk-11.0.2_linux-x64_bin.rpm'
# command = ['rpm', '-Ivh', package_path]
command = ['rpm', '-ivh', package_path]
p = subprocess.Popen(command)
p.wait()
if p.returncode == 0:
print("OK")
else:
print("Something went wrong")
Getting Errors from here onwards
Error in text:
ImportError: Failed to import system RPM module. Make sure RPM Python bindings are installed on your system.
2023-09-30 05:04:01.256 Uncaught app exception
Traceback (most recent call last):
File "/home/adminuser/venv/lib/python3.9/site-packages/rpm/init.py", line 102, in
_shim_module_initializing_NameError: name 'shim_module_initializing' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
exec(code, module.__dict__)File "/mount/src/os_explore/app.py", line 61, in
import rpmFile "/home/adminuser/venv/lib/python3.9/site-packages/rpm/init.py", line 105, in
initialize()File "/home/adminuser/venv/lib/python3.9/site-packages/rpm/init.py", line 94, in initialize
raise ImportError(ImportError: Failed to import system RPM module. Make sure RPM Python bindings are installed on your system.
I would really Appreciate help here as I am stuck on installing Java from days and literally sick & tired of it. My PySpark code is ready in my local app but unable to install Java on cloud.

imagesince it shows bothApp output&errorside by side. And I have put most ofcodeascodehere in this post.erroras text