Google colab file download failed to fetch error
you need to enable third-party cookies
but for now it only works for Chrome browser, open
chrome://settings/content/cookies
make sure the option for Block third-party cookies
is disabled and click add
button in Allow
section then add
colab.research.google.com
I encountered the same problem (MessageError: TypeError: Failed to fetch) while using colab.
then, I split file operations into different code units in a colab notebook; I put file open, write, close in one code unit, and use files.download() in the subsequent code unit.
the problem is gone!
The problem is that the file is not finished being written by the time google attempts to "fetch" the file.
Simple solution:
with open('sampleDictionary.json', 'w') as f:
json.dump(dict, f)
time.sleep(10)
files.download('sampleDictionary.json')
More complicated solution could be put a for loop with a try catch statement for files.download, and then put a sleep in the catch. Keep a max loop time in case the file is never completed.