Receiving 'NAMEERROR:name' when I try and execute my code in DEBUG mode

telconstar99 at gmail.com telconstar99 at gmail.com
Fri Oct 18 13:02:59 EDT 2013


Hey John,

Thanks for the response. I really don't know why I didn't think about that. I decided to add the following statement:

print root

When I RUN, this is what I get:
C:\My Documents\Netbeans\Mytests

When I debug, this is what I get:
C:\Program Files

Having these two directories as different directories is a problem. Any thoughts on how to detect the runtime CWD? C:\Program Files is a pretty unhelpful CWD.

On Friday, October 18, 2013 11:08:26 AM UTC-5, John Gordon wrote:
> In <311c58bc-a826-468f-8c37-cb53600d4383 at googlegroups.com> telconstar99 at gmail.com writes:
> 
> 
> 
> > Hello,
> 
> 
> 
> > I'm writing a testing framework in Jython. My code executes successfully
> 
> > when I RUN my project, however, when I DEBUG my project I receive the
> 
> > following error
> 
> 
> 
> > SOURCE:NAMEERROR:name 'Load_Configurations' is not defined["NameError:
> 
> > name 'Load_Configurations' is not defined
> 
> 
> 
> > I'm new to python. I am using execfile because I want to dynamically
> 
> > include files at runtime. I would appreciate assistance in resolving this
> 
> > error so that I can use a debugger on my project. I'm using Netbeans if
> 
> > that matters. Below I've pasted the code in my runner.py file (the file
> 
> > that gets executed):
> 
> 
> 
> > if __name__ == "__main__":
> 
> >     #Required Imports
> 
> >     import os
> 
> >     import sys
> 
> 
> 
> >     root = os.path.dirname((os.getcwd()))
> 
> 
> 
> >     #Load all my files by walking through my source code
> 
> >     i=1
> 
> >     for r,d,f in os.walk(root + "\\src"):
> 
> >         for files in f:
> 
> >             if (files.endswith(".py") and files!="runner.py" and files!="setup.py" and files!="new_test.py"):
> 
> >                 execfile(os.path.join(r,files))
> 
> >             if i==len(f):
> 
> >                 i=1
> 
> >                 break
> 
> >             i=i+1
> 
> 
> 
> >     #Load Configuration
> 
> >     RunnerSettings.load_config = Load_Configurations(root + '\\configuration.xml')
> 
> 
> 
> I don't know anything about Jython or Netbeans specifically, but looking at
> 
> your code I see that Load_Configurations is, indeed, not defined anywhere.
> 
> It's not imported nor does the code ever create an object with that name,
> 
> so I'm not surprised that you get that error.
> 
> 
> 
> This entire block of code is conditionally executed upon __name__ being
> 
> equal to "main"; perhaps that condition is false when the code is run and
> 
> thus the error is never triggered.
> 
> 
> 
> -- 
> 
> John Gordon         Imagine what it must be like for a real medical doctor to
> 
> gordon at panix.com    watch 'House', or a real serial killer to watch 'Dexter'.



More information about the Python-list mailing list