0
votes

I try to import the following functions:

import numpy as np
def load_labels(path):
   y = np.load(path)
   return y

def print_sentence():
   print("hi")

from a Jupyter notebook, with name "save_load" into another Jupyter notebook with the following code:

!pip install import-ipynb
import import_ipynb
import save_load
from save_load import load_labels, print_sentence

The function print_sentence works fine in the notebook, but with the function load_labels I receive the following error:

NameError: name 'np' is not defined

What could be the reason for this error? I've imported numpy as np in both notebooks.

2

2 Answers

0
votes

In "save_load" instead of import numpy as np try import numpy, it worked for me.

0
votes

You can try this:

import numpy as np or from numpy import *