FileNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs

File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)File "/app/ipl-first-innings-score-prediction/app.py", line 6, in <module>
    pipe = pickle.load(open('E:/projects/ipl project/pipe.pkl','rb'))

please give solution for this error

If your streamlit app runs on a hosted environment, you don’t have access to the Client’s computer.

@Sarang_Gami

This error occurs while running a Streamlit app because the code is trying to load a pickle file from a specific location “E:/projects/ipl project/pipe.pkl”, but that location may not be accessible or may not exist in the current environment where the app is being run.

There are a few potential reasons why this error might be occurring:

  1. The pickle file does not exist in the specified location.
  2. The pickle file exists in the specified location, but the Streamlit app does not have permission to access that file.
  3. The Streamlit app is being run on a different operating system or environment than the one where the pickle file was created, causing compatibility issues.

To fix this error, you can try the following steps:

  1. Double-check the file path to make sure that it exists and is accessible from the current environment.
  2. Make sure that the file has the correct permissions for the Streamlit app to access it.
  3. If the app is being run on a different environment, try re-creating the pickle file on the current environment to ensure compatibility.

thanks sir i changed the file path because this problem is while deploy so i used only ‘pipe.pkl’ and in requirements.txt i added the scikit-learn because of pkl model file… issue is solved…thanks for helping i just made silly mistake.

Hey @Sarang_Gami,

Happy to help, Don’t worry for making mistake. Nobody is perfect. Keep up your work.

2 Likes

I am getting same error while working a lot on this, still it is not resolving. As I have check path of file , persmmission of files also. All of this are ok.

Please help i have deployed my clg project and same issue is showing it is not resolving at all tried so many times but the problem does not solve

i have given the correct path still ,Please help i have deployed my clg project and same issue is showing it is not resolving at all tried so many times but the problem does not solve :pray: :pray: :pray:

Once again: If your streamlit app runs on a hosted environment, you don’t have access to the client’s computer, therefore you cannot use any paths pointing to a local file.

Thanks for reply but is there any way to solve this as I need to deploy the project it runs perfectly on my pc through cmd but can’t deploy

import numpy as np
import pickle
import streamlit as st

Load the model

loaded_model = pickle.load(open(r"C:\Users\Admin\Desktop\ML MODEL\Vibration_Model.sav", ‘rb’))

Load the scaler

scaler = pickle.load(open(r"C:\Users\Admin\Desktop\ML MODEL\scaler.sav", ‘rb’))

Function for prediction

def vibration_prediction(input_data):
# Standardize the input data using the loaded scaler
input_data_reshaped = np.array(input_data).reshape(1, -1)
std_data = scaler.transform(input_data_reshaped)

# Predict using the loaded model
prediction = loaded_model.predict(std_data)

if prediction[0] == 0:
    return 'Manmade'
else:
    return 'Natural'

def main():
# Set background color to blue
st.markdown(
“”"

body {
background-color: #00BFFF;
color: #FFFFFF;
text-align: center;
}
.title {
color: #0000FF; /* Blue color */
font-size: 36px;
margin-bottom: 30px;
}

“”",
unsafe_allow_html=True
)

# Giving a title
st.markdown("<h1 class='title'>VIBRATION SOURCE PREDICTION</h1>", unsafe_allow_html=True)

# Getting input data from user
Vibration = st.text_input('Enter Vibration')
Amplitude = st.text_input('Enter Amplitude')
Duration = st.text_input('Enter Duration')
Peak_to_Peak_Vibration = st.text_input('Enter Peak-to-Peak Vibration')

# Creating button for prediction
if st.button('Predict Vibration Source', key='prediction_button'):
    # Convert input data to float
    try:
        input_data = [float(Vibration), float(Amplitude), float(Duration), float(Peak_to_Peak_Vibration)]
        diagnosis = vibration_prediction(input_data)
        st.success(f"The vibration source is predicted to be: {diagnosis} origin ")
    except ValueError:
        st.error('Please enter valid numerical values for all input fields.')

if name == ‘main’:
main()
this the code working perfectly on local host but showing file not found error wheni deploy pls help me out

Put your model files also under git control and load them from there with a relative path instead of your local files absolute path. This will work both on your local computer and on streamlit cloud.

Thanks for replying i am just a beginner can you pls help me out this is my repository GitHub - larvae1/Vibration_ML_Model: ML Model to analyse the source of vibration

full code is :
import streamlit as st
import numpy as np
import pickle

Load the model

loaded_model = pickle.load(open(r"C:\Users\Admin\Desktop\ML MODEL\Vibration_Model.sav", ‘rb’))

Load the scaler

scaler = pickle.load(open(r"C:\Users\Admin\Desktop\ML MODEL\scaler.sav", ‘rb’))

Function for prediction

def vibration_prediction(input_data):
# Standardize the input data using the loaded scaler
input_data_reshaped = np.array(input_data).reshape(1, -1)
std_data = scaler.transform(input_data_reshaped)

# Predict using the loaded model
prediction = loaded_model.predict(std_data)

if prediction[0] == 0:
    return 'Manmade'
else:
    return 'Natural'

def main():
# Set background color to blue
st.markdown(
“”"

body {
background-color: #00BFFF;
color: #FFFFFF;
text-align: center;
}
.title {
color: #0000FF; /* Blue color */
font-size: 36px;
margin-bottom: 30px;
}

“”",
unsafe_allow_html=True
)

# Giving a title
st.markdown("<h1 class='title'>VIBRATION SOURCE PREDICTION</h1>", unsafe_allow_html=True)

# Getting input data from user
Vibration = st.text_input('Enter Vibration')
Amplitude = st.text_input('Enter Amplitude')
Duration = st.text_input('Enter Duration')
Peak_to_Peak_Vibration = st.text_input('Enter Peak-to-Peak Vibration')

# Creating button for prediction
if st.button('Predict Vibration Source', key='prediction_button'):
    # Convert input data to float
    try:
        input_data = [float(Vibration), float(Amplitude), float(Duration), float(Peak_to_Peak_Vibration)]
        diagnosis = vibration_prediction(input_data)
        st.success(f"The vibration source is predicted to be: {diagnosis} origin ")
    except ValueError:
        st.error('Please enter valid numerical values for all input fields.')

if name == ‘main’:
main()

very much thank you

Don’t use absolute paths.
Just use the relative paths to your model files e.g.

loaded_model = pickle.load(open("Vibration_Model.sav", "rb"))
...
scaler = pickle.load(open("scaler.sav", "rb"))

This works both local and on streamlit cloud.

showing this error now what to do?

please help it is really needed

typo: requirements.txt

can you elaborate pls? i did not understood

sir pls help me in its deployment

corrected the typo but still showing module not found sklearn but i have installed it