'FileNotFoundError: [Errno 2] No such file or directory: 'new_model.pkl'

I have created a .pkl file in Jupyter notebook as the following:

import pickle
pickle.dump(rfc, open('new_model.pkl', 'wb'))

This file is saved in the folder I am working in.

I am using Spyder to deploy my web application, the code is as follows:

import streamlit as st
import numpy as np
import string
import pickle

model = pickle.load(open('new_model.pkl','rb'))

When launching streamlit I am getting this error:

FileNotFoundError: [Errno 2] No such file or directory: 'new_model.pkl'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source