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'))
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:
The pickle file does not exist in the specified location.
The pickle file exists in the specified location, but the Streamlit app does not have permission to access that file.
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:
Double-check the file path to make sure that it exists and is accessible from the current environment.
Make sure that the file has the correct permissions for the Streamlit app to access it.
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.
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.
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
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.
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.
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.')
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.