Is there anyway I can download the file in Google colaboratory?

Anirudha Gupta picture Anirudha Gupta · Mar 30, 2018 · Viewed 13.3k times · Source

I am trying tensorflow in Google Colaboratory from this codelab, I need to download 'http://download.tensorflow.org/example_images/flower_photos.tgz' this file to complete the lab.

How I can download the file. Is there anyway to upload the tar file without downloading it on my machine.

I tried this method

import urllib
testfile = urllib.URLopener()
testfile.retrieve("http://randomsite.com/file.gz", "file.gz")

This doesn't work, wget is not found also. Anyone please tell me how to do this.

Answer

Bob Smith picture Bob Smith · Mar 30, 2018

Possibly simpler: use !wget, e.g., executing a cell with the command:

!wget https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png

will save the file to the local filesystem of the VM. (Note the leading !. This is a signal to execute the line as a shell command.)