[wingide-users] Debugger fails if directory contains file named warnings.py

Donovan Eastman dpeastman at gmail.com
Fri Dec 10 18:22:25 MST 2010


I ran into a strange problem yesterday... I created a project in Wing for
some code I wanted to look at.  When I tried to run the code, all I got was
an "ImportError: Could not import netserver" error.  (I've pasted the entire
error message from the Debug I/O below.)

I thought this was odd since everything had been working previously.  The
code ran fine outside of Wing.  The code in question didn't do anything
particularly unusual (and the debugger failed before running any of it
anyway).  As I fiddled with settings I would often get the same error
message in Wing's Python Shell window as well, although it seemed kind of
erratic.

Eventually I figured out that the problem was caused by having a file called
warnings.py in the same folder.  Although this warnings.py wasn't called by
any of the code I was trying to run it was interfering with the warnings
module from the standard library.

I was able to work around the problem by explicitly adding Python's Lib
folder to the project's custom Python Path.  (If the path containing the
"wrong" warnings.py is also in the Python Path, Lib must come first.)

This is not strictly a Wing issue: Giving a module the same name as a
standard library module is usually a bad idea, especially one with
generalized usage, like warnings.  If, for example, you try to use a
deprecated function in a module in the same directory as a warnings.py file,
your code will fail, even from the command line.  Having said that, your
code would fail in a way that made it fairly easy to identify the issue.
 The problem I had with Wing is that the error message didn't give me any
clue as to where to look.

Donovan


Complete error message:

Traceback (most recent call last):
  File "C:\Program Files\Wing IDE 3.2\bin\wingdb.py", line 542, in main
    netserver = FindNetServerModule(winghome, user_settings)
  File "C:\Program Files\Wing IDE 3.2\bin\wingdb.py", line 362, in
FindNetServerModule
    raise ImportError('Could not import netserver')
ImportError: Could not import netserver
wingdb.py: Error: Failed to start the debug server
wingdb.py: Error: You may be running an unsupported version of Python
wingdb.py: Python version = 3.1.3 (r313:86834, Nov 27 2010, 18:30:53) [MSC
v.1500 32 bit (Intel)]
wingdb.py: WINGHOME='C:\\Program Files\\Wing IDE 3.2'
Traceback (most recent call last):
  File "C:\Program Files\Wing IDE 3.2\bin\wingdb.py", line 542, in main
    netserver = FindNetServerModule(winghome, user_settings)
  File "C:\Program Files\Wing IDE 3.2\bin\wingdb.py", line 362, in
FindNetServerModule
    raise ImportError('Could not import netserver')
ImportError: Could not import netserver

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Wing IDE 3.2\bin\wingdb.py", line 553, in main
    sys.exit(-1)
SystemExit: -1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/wingide-users/attachments/20101210/8dae4e9a/attachment.html


More information about the wingide-users mailing list