Wednesday, February 5, 2020

python object has no attribute


Yesterday I was trying to write some Python classes in a code editor and was trying to use that classes inside Jupyter Notebook. I had made all changes I needed to make in the class and wanted those changes to be reflected in the notebook. I kept on getting this error, while trying to access the methods which were defined in the class. I had updated sys.path to contain the directory which had code.

python object has no attribute

I searched high and low on the google about why this error was showing up. I just could not understand. I had not made any mistake in the spelling. I had made sure all the indentation of the class was appropriate. I stepped away from the computer and made dinner. After coming back, I thought of trying something, just shut down Anaconda environment and restart notebook. Once I did that, the methods from class started showing. If I made changes, then I just clicked Restart the Kernel button which looks like a circle in Jupyter notebook. Once that problem was sorted, I was able to see the changes I made.

Lessons learned:


  1. When problem does not seem to solve itself even after lot of tries, step away from it.
  2. Restarting the kernel helps in Jupyter notebook.