Home > Enterprise >  Why does Python error code 'name is not defined' appear after you left the jupyter noteboo
Why does Python error code 'name is not defined' appear after you left the jupyter noteboo

Time:12-29

Name is not definedI was working on Jupyter Notebook and ended up saving the notebook after working for hours, now when I want to return back the notebook is giving me errors. I thought by saving it and coming back the next day I will find it where I previously left it and would continue from there but as I continue it gives me the error code name is not defined

I tried import pandas and numpy and was expecting the error code to stop

CodePudding user response:

When you save a notebook it only saves the python code in the cells and their respective outputs if there are any.

Saving a notebook does not mean that you can just start it from where you left it, meaning that the variables which you initialised are lost once you turn off the jupyter notebook kernel. All you need to do is re-run each cell in your notebook and all the variables will load since they have to be in the notebook. Hope this helps!

CodePudding user response:

Re-run all the cells from the top down.

In one of the previous cells you defined / imported normal_rets. But until you run that specific cell again, the notebook doesn't know what normal_rets is.

When you save the notebook, you effectively save the code / instructions. But you need to re-run the code cells when you come back to the notebook so that all of the functions / modules / variables and their contents are re-loaded into memory so you can use them again.

  • Related