<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>NameError on ErrorVault — Developer Error Code Dictionary</title><link>https://errorvault.dev/tags/nameerror/</link><description>Recent content in NameError on ErrorVault — Developer Error Code Dictionary</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 12 Apr 2026 22:22:17 +0800</lastBuildDate><atom:link href="https://errorvault.dev/tags/nameerror/feed.xml" rel="self" type="application/rss+xml"/><item><title>Fix NameError: Python undefined variable or function reference error</title><link>https://errorvault.dev/python/python-nameerror-undefined-variable/</link><pubDate>Sun, 12 Apr 2026 22:22:17 +0800</pubDate><guid>https://errorvault.dev/python/python-nameerror-undefined-variable/</guid><description>&lt;h2 id="1-symptoms">1. Symptoms&lt;/h2>
&lt;p>NameError in Python occurs at runtime when code references a name (variable, function, class, or module) that is not defined in the current scope. The traceback typically shows:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span style="display:flex;">&lt;span>Traceback (most recent call last):
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> File &lt;span style="color:#f1fa8c">&amp;#34;example.py&amp;#34;&lt;/span>, line &lt;span style="color:#bd93f9">5&lt;/span>, &lt;span style="color:#ff79c6">in&lt;/span> &lt;span style="color:#ff79c6">&amp;lt;&lt;/span>module&lt;span style="color:#ff79c6">&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8be9fd;font-style:italic">print&lt;/span>(undefined_var)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>NameError: name &lt;span style="color:#f1fa8c">&amp;#39;undefined_var&amp;#39;&lt;/span> is &lt;span style="color:#ff79c6">not&lt;/span> defined
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Key indicators:&lt;/p>
&lt;ul>
&lt;li>Error message: &lt;code>NameError: name '{name}' is not defined&lt;/code>&lt;/li>
&lt;li>Points to the exact line with the undefined reference.&lt;/li>
&lt;li>Common in scripts, functions, or after conditional definitions.&lt;/li>
&lt;li>No issue during syntax parsing; fails on execution.&lt;/li>
&lt;/ul>
&lt;p>Variations include references to misspelled variables, functions called before definition, or globals accessed incorrectly in functions. IDEs like VS Code or PyCharm highlight these as warnings pre-runtime.&lt;/p></description></item></channel></rss>