How to import from one Google colab notebook to the other?

Viewed 1083

I wish to work on Colab to run a ResNet, but every time I try to import the notebook of the ResNet to my main notebook I get an error. I've tried many ways.

First:

%load_ext autoreload
%autoreload 2
from google.colab import drive
drive.mount('/content/drive')
import os
GOOGLE_DRIVE_PATH_AFTER_MYDRIVE = None
GOOGLE_DRIVE_PATH = os.path.join('drive', 'My Drive', 'FinalsProject')
print(os.listdir(GOOGLE_DRIVE_PATH))
import sys
sys.path.append(GOOGLE_DRIVE_PATH)

I can clearly see that the notebook that I need is there and this notebook is at the same location.

But when I do import I get an error.

The file name is 'resnet01.ipynd'

1. A simple:

import resnet01

returns the error message:

ModuleNotFoundError: No module named 'resnet01'

The code:

!pip install python-ipynb
import import_ipynb

The error message:

ERROR: Could not find a version that satisfies the requirement python-ipynb (from versions: none)
ERROR: No matching distribution found for python-ipynb

The code:

!pip install ipynb
import ipynb.fs.full.resnet01 as models

The error message:

ImportError: Could not import drive/My Drive/FinalsProject/resnet01.ipynb for ipynb.fs.full.resnet01: incorrect version or language.

Is there any way to make it work? Or should I do it in another way...?

1 Answers
Related