I have exhausted gemini, trying to figure out why i am receiving an error message while trying to pickle a ML model for a data project. I would appreciate any advice that someone can give me. I have the correct file path. I don't know if it is a cloud issue, but i moved the folder to my local device and it is still giving me the error message.
FileNotFoundError: [Errno 2] No such file or directory: '/Users/michael/Google_rf/hr_rf1.pickle'
this is the function i am trying to use ....
def write_pickle(path, model_object, save_as:str): with open(path + save_as + ".pickle", "wb") as to_write: pickle.dump(model_object, to_write)
and i put my file path in before the function ..
path = "/Users/michael/Google_rf/"
then i called it like this .....
write_pickle(path, rf1, 'hr_rf1')
I switched the folder over to my local drive. I made sure the jupyter notebook kernal was set for python. I checked the spelling and confirmed the file path, etc..
I have exhausted gemini, trying to figure out why i am receiving an error message while trying to pickle a ML model for a data project. I would appreciate any advice that someone can give me. I have the correct file path. I don't know if it is a cloud issue, but i moved the folder to my local device and it is still giving me the error message.
FileNotFoundError: [Errno 2] No such file or directory: '/Users/michael/Google_rf/hr_rf1.pickle'
this is the function i am trying to use ....
def write_pickle(path, model_object, save_as:str): with open(path + save_as + ".pickle", "wb") as to_write: pickle.dump(model_object, to_write)
and i put my file path in before the function ..
path = "/Users/michael/Google_rf/"
then i called it like this .....
write_pickle(path, rf1, 'hr_rf1')
I switched the folder over to my local drive. I made sure the jupyter notebook kernal was set for python. I checked the spelling and confirmed the file path, etc..
Share Improve this question edited Nov 20, 2024 at 20:24 M_Sabatino asked Nov 20, 2024 at 18:34 M_SabatinoM_Sabatino 12 bronze badges 2 |1 Answer
Reset to default 0You need to format your code to make it more readable. Make sure python is running from the directory you think it is.
In your script you can simply add
import os
print(os.getcwd())
to view the actual directory you are running in. From there you can update your path as necessary.
pwd
run in cells in your notebook to see where you are in your file hierarchy and then use%cd
to change the working directory and usels
to see what is in the current directory. Then using those, troubleshoot what your notebook can see and demonstrate in your post to us about the presence of/Users/michaelsabatino/Google_rf/
. Also, did you trypath = r"/Users/michaelsabatino/Google_rf/"
? – Wayne Commented Nov 20, 2024 at 19:34