Accessing Google Drive and creating your first Python script in Google Colab — A complete beginners walkthrough
Google Colab is an excellent cloud-based Jupyter notebook environment in which to code and run your Python scripts. And, as the saying (or as the Flying Lizzards would say) “the best things in life are free” and that’s exactly what Colab is! It’s completely free to anybody with a Google account. It allows you access to a GPU processor when you need to train your AI model allowing rapid training times as opposed to training on your local computer’s CPU.
Let’s go over accessing the Google Colab environment from Google Drive…
…First and foremost you will need a Google Account. If you don’t have one, sign up to it, it’s completely free: https://accounts.google.com/signup
Google gives you 15GB of space for free! That’s ample space to save your files and upload any small to medium sized data-files. The chances are that you’re already using the world’s most popular web browser, Google Chrome, if not download it and sign into the browser so you can access Google Drive (amongst other applications ). If you are already using another browser (such as Safari) you will still have to sign into Google to access your Google Drive.
Once signed into Google Chrome click on the Google Apps icon on the right-hand-side of the screen, then click on Drive:
Your display will look similar to this but without the files and folders which I’ve created previously:
How you structure this is entirely your choice. I created some folders and subfolders to organise my scripts and food recipes etc.
To create a folder, simply right mouse click over the Google Drive area which opens a menu and left click on ‘New folder’:
Give it a name of your choice. Don’t include white spaces between the words (it’s entirely legal but may cause issues when defining this folder from which to upload/download data), instead use the underscore key and click on ‘Create’:
The empty folder will be created which is shown in the Folders section:
Simply double click on the newly created folder to access it:
Now to create your very first Google Colab file. Simply right mouse click anywhere in this area and highlight More, then from the sub-menu click on Google Colaboratory:
You will be presented with the following:
Rename the file by clicking on ‘Untitled0.ipynb’ and rename it to something meaningful (if you don’t Colab will save this file as Untitled0.ipynb):
Hover over the code bar and two buttons will show: Code and Text. Simply click on the ‘Text’ to add a text cell above the current code cell:
You can insert free text, URL hyperlinks, images, numbered points and bullet points here:
Once done, simply click off in the white space below. Hover the mouse just slightly below the inserted text to show the ‘Code’ and ‘Text’ buttons again. Click on the ‘Code’ button…
Now you’re ready to start coding in Python. Write some python code and when you want to execute it simply click on the play icon on the left-hand-side:
Python output is shown in the box just below…
If you’ve followed this guide verbatim you would have got the same output as shown above. If you did, congratulations, you’ve just created your first python script and executed it in Google Colab successfully.