admin管理员组文章数量:1333710
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.
本文标签: pythonCan anyone help me with a FileNotFoundErrorStack Overflow
版权声明:本文标题:python - Can anyone help me with a FileNotFoundError? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742337368a2455895.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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