Parthapratim Neog
Parthapratim Neog

Reputation: 4478

How to run a downloaded Jupyter notebook on Google Colaboratory?

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?

Upvotes: 20

Views: 35948

Answers (8)

FlashDD
FlashDD

Reputation: 438

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.

Upvotes: 1

Vikranth
Vikranth

Reputation: 1748

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.

Upvotes: 0

Teja Sruthi Varanasi
Teja Sruthi Varanasi

Reputation: 65

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.

Upvotes: 0

coolwa
coolwa

Reputation: 1

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

Upvotes: 0

Agile Bean
Agile Bean

Reputation: 7151

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

Upvotes: 3

Sebas Arango
Sebas Arango

Reputation: 341

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.

Upvotes: 20

korakot
korakot

Reputation: 40828

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

Upvotes: 4

Arpit Gupta
Arpit Gupta

Reputation: 511

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.

Upvotes: 0

Related Questions