Why am I getting NameError name ' ' is not defined in another cell?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 04:33 PM
I defined a dictionary variable Dict, populated it, and print(dict) in the first cell of my notebook. In the next cell, I executed the command print(dict) again. However, this time it gave me an error
NameError: name 'Dict is not defined
How can that be? Why am I able to print this variable in one cell, but unable to do so in the next cell?
- Labels:
-
Cell
-
Copy File Path
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 05:20 AM
I am facing the same issue while executing a job currently. Was a cause/solution found for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 09:48 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2023 09:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 06:19 AM
I can confirm that your answer at least pointed me in the right direction.
It seems my issue wasn't exactly the same as I was instead using the magic pip command to install a notebook scoped package:
%pip install <some-package>
Anything defined within that command cell seems to be lost so I had to separate this into it's own command before everything else.
Thank you for the help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 07:20 AM
Running pip install restarts the interpreter, meaning that any variable defined prior to the pip install is lost, so indeed the solution is so run the pip install first, or better is to add the library you want to installl directly to the cluster configuration

