import wx not working in uncompiled scripts
Question: I have installed Python 2.7.5 and wxPython 2.8.12.1 on my new Windows 7
machine, and the 'import wx' statement doesn't work when I try to run the
containing .py script directly from the Windows command prompt or from the
Windows explorer. (It does work in the compiled .pyc file, or if I run the
script from the interactive interpreter using import, or using the python
command at the Windows command prompt.)

The script looks like this:

    
    
    import wx
    print wx.version()
    raw_input("Test runs OK - hit Enter to exit")
    

In the failure case, the output looks like this:

Traceback (most recent call last): File "C:\First Python
Project\src\root\nested\test.py", line 2, in ? print wx.version()
AttributeError: 'module' object has no attribute 'version'

I suspect this has something to do with my wxPython installation, because
'import os' works fine however I run the script.

Thanks for any help. I've looked but can't find this question elsewhere.


Answer: My guess is you may have named one of your scripts "wx.py" in C:\First Python
Project\src\root\nested. If so, you are shadowing wxPython itself. Python will
import you wx.py because it's first on the path and it won't even try to
import the right one. That's my guess anyway.

