[Tutor] name 'sys' is not defined ?

pan at uchicago.edu pan@uchicago.edu
Mon Aug 4 22:31:02 EDT 2003


I've encountered some bug(s) that's driving me crazy. A simple code as
follows:

[1] import sys
[2] cgiFolder=r'D:\pan\pc\prog\lang\py\mymod\cgi'
[3] if cgiFolder not in sys.path: sys.path.append(cgiFolder)

[4] import treeNode
[5] from treeNode import c_treeNode

gives me an error 

    NameError: name 'sys' is not defined

at line [3] when it is first executed, and then:

    ImportError: cannot import name c_treeNode

at line [5] if it runs the 2nd time (means, the 'sys' error
in the first run no longer exist).

I am pretty sure that the c_treeNode class in the treeNode.py file
exists and runs correctly.

What is weird is, the above code was executed nicely last week 
without any error. When I came back to the office after the weekend,
everything went wrong. 

I've been using python 2.2.1 with pythonwin. I thought something went
wrong with either of them so I uninstalled them and installed a new
version of 2.2.2 but the problem persists.

Anyone has any idea?

pan




More information about the Tutor mailing list