0

I'm having some trouble with imports in Jupyter Notebook. My directory structure is as follows: https://i.stack.imgur.com/Bfxjx.png.

In my Cost function.ipynb I wrote the following:

import numpy as np
import matplotlib.pyplot as plt
from lab_utils_uni import plt_intuition
plt.style.use('deeplearning.mplstyle')

However I got TypeError: the 'package' argument is required to perform a relative import for './deeplearning'.

To try to fix this, I added '.' in front of lab_utils_uni like this:

from .lab_utils_uni import plt_intuition

But this resulted in ImportError: attempted relative import with no known parent package.

How can I fix this issue?

tadman
  • 208,517
  • 23
  • 234
  • 262
Trieu Vu
  • 1
  • 2
  • I don't think you need to add the dot (you can find the reason why [here](https://stackoverflow.com/questions/16981921/relative-imports-in-python-3)). Do you happen to call `importlib.import_module('./deeplearning')` somewhere in your project? That's what is causing the `TypeError`. – lorsanta Apr 30 '23 at 13:54
  • all i write is like above , nothing else – Trieu Vu Apr 30 '23 at 15:27

0 Answers0