W1 (code not running) TypeError: the 'package' argument is required to perform a relative import for './deeplearning'

Hello everyone here I hope you are all well :slight_smile :slight_smile:

import math, copy
import numpy as np
import matplotlib.pyplot as plt
from lab_utils_uni import plt_house_x, plt_contour_wgrad, plt_divergence, plt_gradients

While I am using this code
TypeError: the ā€˜packageā€™ argument is required to perform a relative import for ā€˜./deeplearningā€™
is showing rn.
While I have installed the source code file to Jupyter Notebook

So, you are replicating the assignments on your local computer.

Note that it needs some effort. To create a local environment in your PC/Laptop, read this. Itā€™s a bit complex process, so, you can use Colab. Read this guide.

Hello, Thanks for your reply it was deeply appreciated.

import numpy as np
import matplotlib.pyplot as plt
Both are working on my local computer.

While both
from lab_utils_uni import plt_intuition, plt_stationary, plt_update_onclick, soup_bowl
plt.style.use(ā€˜./deeplearning.mplstyleā€™) gave me this message
TypeError: the ā€˜packageā€™ argument is required to perform a relative import for ā€˜./deeplearningā€™
is showing rn.

1 Like

Hello @Amr_Shaaban_Dahab,

Which version of matplotlib are you using? There seems to be a relevant report on that, and check it out. My matplotlib (version 3.6.2) works fine.

Btw, I found the above report by googling "plt.style.use TypeError: the ā€˜packageā€™ argument is required to perform a relative import for".

Cheers,
Raymond

Hi, all!

The only solutions I find in the report are ā€œā€¦ either to also catch TypeError in style/core.py, or to explicitly check for pkg not being empty? [sic]ā€ Unfortunately, I do not know how to do either. Note that sometimes I can get rid of the error by removing the ā€˜./ā€™ before ā€˜deeplearning.ā€™

Cheers,
Dave