Search code examples
pythonambiguous

Python - very ambiguous error message


I'm working on a large scale software system written in Python right now, which includes multiple modules. I was wondering what I should do about this, if anyone could make any sense of this error message that I keep receiving:

  File "<string>", line 1, in <module>
NameError: name 'CerealObject' is not defined

The thing that makes it very cryptic is that it seems to not provide an actual file name or a specific module. From a beginner's standpoint this makes it seem impossible to debug.


Solution

  • File "<string>" in an exception stack trace typically means that you're using either exec or eval somewhere. They execute code from a string, hence the lack of an actual file name.

    You'll need to look at the following line(s) of your stack trace to determine the source of the problem.