Issue
I saved the day's work in jupyter notebook. When I opened it the next day, it showed me all the code I'd written and lines that I had executed. However, when i try to run code with content defined from yesterday, it's not working. For example, if I defined a variable yesterday, saved that code and tried to run it today by calling that variable in a new line of code it shows 'variable not defined'. enter image description here
Solution
A Jupyter notebook is a JSON file that serves as complete computational record of a session
, which especially includes code cells and output cells.
As written in the documentation each Jupyter notebook is associated with a single kernel
, which can be considered as the computational engine
of a Jupyter notebook. Executing code in a code cell, loosely speaking, is not really different then executing any other Python program. Your variables, your functions, etc. are stored in memory. If the kernel is shutdown, the memory will be released. The state of execution
will not be stored in the JSON file of the Jupyter notebook.
Thus, if you shutdown the kernel and restart it the next day, the output cells suggest that everything is in the same state as before but it really isn't. You have to run each cell again.
There is a convenient way to do this in Jupyter by executing all cells at once by using Cell -> Run All
.
Answered By - David Scholz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.