I want to download kaggle's dataset automaticly on Github Action's server, and this is my code:
json_str = '{"username":"headwater","key":"My key"}'
if is_64bit_ubuntu():
with open('/home/runner/.kaggle/kaggle.json', 'w+') as fp:
fp.write(json_str)
elif is_windows():
with open('C:\\Users\\runneradmin\\.kaggle\\kaggle.json', 'w+') as fp:
fp.write(json_str)
I'm sure this code can run on my local machine, however when I put it on Github, it occurs error like this:
> with open('/home/runner/.kaggle/kaggle.json', 'w+') as fp:
E FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/.kaggle/kaggle.json'
So how to solve this?
Bijay Regmi: Looks like your .kaggle directory does not exist so the file is not written there. Use os.mkdir("/home/runner/.kaggle") before writing file into it.