0

I have this in my python file (called myLib.py)

def add(x, y):
    return x + y

and in my jupeter notebook I have this code:

import myLib as myLib
y=myLib.add(1,2)
print(y)

when I run the jupyter cell,I m getting this error:

AttributeError                            Traceback (most recent call last)
<ipython-input-10-9b942a9ce18f> in <module>
      1 import myLib as myLib
----> 2 y=myLib.add(1,2)
      3 print(y)

AttributeError: module 'myLib' has no attribute 'add'

I am using visual studio

What is the problem and how I can fix it?

mans
  • 17,104
  • 45
  • 172
  • 321
  • 2
    Did you edit `myLib.py` while running the jupyter notebook?https://stackoverflow.com/questions/52400814/reload-python-module-within-jupyter-notebook-without-autoreload – Håken Lid Feb 17 '21 at 22:34
  • myLib.py should be in the same folder as your jupyter notebook (.ipynb) – sdzt9 Feb 17 '21 at 22:37

0 Answers0