18

I am using Google Colaboratory & github. I create a new Google Colab notebook, and I clone my github project into it using a simple !git clone <github_link> in the notebook.

Now, I have a Jupyter notebook in my github project that I need to run on Google Colab. How do I do that?

Parthapratim Neog
  • 4,352
  • 6
  • 43
  • 79
  • 1
    I want to do the same, I thought of running the `!Jupyter notebook` command inside my already existing colab notebook so that I can run the downloaded Jupyter notebook from Github repo. But its starting in localhost and I don't know how to get IP to run that in my browser. – Aptha Gowda Sep 27 '18 at 05:57

8 Answers8

16

There is not a real need of downloading the notebook. If you already have your Notebook in a GitHub repo, the only thing you need to do is:

And that should work.

Sebas Arango
  • 301
  • 2
  • 4
  • Nice thing is that when choosing the above, it will load all other notebooks existing in that repo. – Orco Jun 30 '20 at 20:34
4

You can upload the notebook to google drive first, then open it from there.

  • go to drive.google.com
  • go into directory “Colab Notebooks”
  • choose “New” > File upload
  • After uploading, click the new file
  • Chose “Open with Colaboratory” at the top
korakot
  • 37,818
  • 16
  • 123
  • 144
  • I know that, but I cannot do that. I have to download it from within the first notebook, and then open it. Since this is a git clone, the data pulled from git is not there in my drive, and as such I cannot open it from Google Colab – Parthapratim Neog Feb 26 '18 at 06:15
3

The two most practical ways are both through the Google Drive webinterface.

The first method is what @Korakot Choavavanich described. The advantage of this method is that it provides a Search window to search for your file in your google drive storage.

The second method is even more convenient - and maybe more appropriate for your case:

In the Google Drive webinterface, you navigate to your folder where your file is located - in your case within the cloned github repository.

Then (see screenshot):

right-click on the file | Open with | Colaboratory

Your file is then converted into a colabo notebook automatically (it takes at least half a minute for that). The advantage with this method is that you can create the colabo file directly in the folder. My tip is to create a copy of the original jupyter file (I added "COLABO" in the file name) as you will have different code to sync your google drive and save files than in a local jupyter notebook.

enter image description here

Agile Bean
  • 6,437
  • 1
  • 45
  • 53
0

One of the way could be that you can connect your google drive with the Colaboraty notebook using the following link:

Link to images within google drive from a colab notebook

Post which you can download your github repo in your google drive location. Then browse through your google drive and open the notebook using Colaboratory itself.

Arpit Gupta
  • 501
  • 1
  • 5
  • 14
0
import sys, os

sys.path.append('models/research')

sys.path.append('models/research/object_detection')

It helped me. I was also looking for it, and found it in this COLAB work

https://colab.research.google.com/drive/1EQ3Lt_ez-oKTtVMebh6Tm3XSyPPOHAf3#scrollTo=oC-_mxCxCNP6

Pika Supports Ukraine
  • 3,612
  • 10
  • 26
  • 42
coolwa
  • 1
0

It may be a new feature not mentioned in other answers. But right now Colab allows running jupyter notebooks directly from github, even from private repos.

  1. Login to your google account
  2. Access colab.research.google.com
  3. Select the GitHub tab.
  4. Choose include private repository if needed.
  5. Go through the authentication process in the new opened window
  6. Select from your repos and notebooks

And clone your repo from inside the opened notebook.

Community
  • 1
  • 1
FlashDD
  • 418
  • 4
  • 14
0

The better option I have found is copying the code from each cell and executing the code in colab, if you clone the Github and containing ipynb file in that. By doing this you won't face any difficulties.

0

Upload the .ipynb file directly in colab. Just go to colab, in the tabs above there should be upload. choose the file and upload there.

Vikranth
  • 1,538
  • 1
  • 14
  • 23