Jupyter cells can't reference earlier cells

Hi guys. I’ve noticed that all of the Jupyter labs and assignments have an issue for me: many of the cells fail to reference earlier cells. This means that cells that define imports, functions and variables are not reachable by later cells and I am constantly getting errors that say NameError: name ‘example_name’ is not defined until I paste in the information from other cells. It makes it difficult with assignments because I cannot run the tests which reference the functions I’ve coded so I have to check my work by just pressing submit a bunch of times. This has been an issue since the first course. Wondering if there is a solution?

Hello, @crossecodes,

That’s a strange behavior. However, it is hard to recommend a solution because you have only described some symptoms but we still do not know the cause yet.

Normally, after we run the cell that defines the variable successfully, the variable will be in the memory ready to be referenced to later. However, the memory is reset if the Python kernel is restarted or it can be reset if we close and restart the assignment.

Therefore, every time we (re-)open an assignment, we need to successfully run every cell in order starting from the first one. In that case, we should see increasing numbers in the left hand side of each cell.

If you open course 2 week 1 assignment now on Cousera and run every one of the cells in sequence, I recommend you to pay attention to the following details:

Cheers,
Raymond

1 Like

Every time you open a notebook, you have to run all of the cells starting from the top. That’s where the workspace is created.

Your workspace is not saved along with your notebook when you exit.

So you have to re-create the workspace every time.

Thanks Raymond, I just wasn’t running the cells in order, because I’d just read over some without running them. Now I just run all cells before working through the lab to avoid this issue :slight_smile:

1 Like

You are welcome, @crossecodes! :wink: :wink: