I got error when I run this line,
(path/‘to.pkl’).save(to)
AttributeError Traceback (most recent call last)
in () ----> 1 (path/‘to.pkl’).save(to)
AttributeError: ‘PosixPath’ object has no attribute ‘save’
I already used ’ !pip install fastai --upgrade’
any suggestions?
1 Like
kelwa
(Moaz)
October 11, 2020, 9:07am
2
I think you need to restart your timeline after doing this, worked for me
1 Like
mikeee
October 13, 2020, 3:00pm
3
Got the same problem – done pip install fastai -U
, restarted runtime with ctrl-M .
, save
is not available for Path, dir(Path) shows that 'ls',
save_array’ etcare there,
save` is not there.
# dir(Path)
['__bytes__',
'__class__',
'__delattr__',
...
'load_array',
'ls',
...
'samefile',
'save_array',
'stat',
'stem',
...
'write_text']
Any help would be much appreciated.
muellerzr
(Zachary Mueller)
October 13, 2020, 3:03pm
4
There was a breaking change, you can see in the fastcore changelog:
1.1.0
Breaking Changes
Remove Path.{read,write}
(use Path.{read_text,write_text}
instead) and change Path.{load,save}
to functions load_pickle
and save_pickle
(#121 )
2 Likes
mikeee
October 13, 2020, 4:25pm
6
Well, save_pickle didnt work either. pickle.dump(to, open(path/'to.pkl', 'wb'))
seems to do the trick.
Not sure why Path.save
doesnt work, maybe I didn’t do some necessary from x import *
, quite some to import, plus it’s not too clear which is for which.
kozer
(Antony)
October 17, 2020, 8:01am
7
With the current version (17/10/2020 - v1.2.0) it should be:
Save file:
save_pickle(path/'to.pkl',to)
Load file:
load_pickle(path/'to.pkl')
18 Likes
thetj09
(Thej Ravichandran)
December 21, 2020, 7:34pm
10
@MinYong_Choi please mark this as the right answer. It works for me and several others it looks like.
shiro12
February 1, 2021, 2:20am
11
@kozer This works perfectly, thanks!