'PosixPath' object has no attribute 'write'

I’m going through chapter 9 using Google Colab but I run with this error. I spent a couple of hours trying to figure it out but couldn’t.

!pip install fastcore
!pip install fastai
!pip install fastai --upgrade
!pip install kaggle

from fastai.tabular.all import *

creds = '{"username":"xxx","key":"xxx"}'

cred_path = Path('~/.kaggle/kaggle.json').expanduser()
if not cred_path.exists():

it’s showing the following:

'PosixPath' object has no attribute 'write'

It seems that fastai patches the Pathlib module with a new attribute write but why it’s not working?

1 Like

Are you sure it patches that function? If yes, can you point out where in the library?

Pathlib has .write_text and .write_bytes natively, maybe the former could do what you’re trying to do.

I tried to import pathlib

from pathlib import *

but it still gives the same error message.
This is my notebook if you can manage to make it work

Regardless if it patches the function or not, it doesn’t work.

Looks like write is removed from fastcore utils and got replaced with mk_write

Version where it got removed


Thank you so much :smile: