[Tutor] WxPython

D-Man dsh8290@rit.edu
Mon, 9 Apr 2001 11:17:26 -0400


On Mon, Apr 09, 2001 at 07:56:54AM -0700, Stevenson Hickey wrote:
| 
|    I downloaded WxPython for Python 2.0 and installed it from the
|    download just by clicking on it.  It seemed to install properly, but
|    when I went to do the demo as instructed, I could not get it from
|    Windows.  I went into Cygwin and went to the directory and typed
|    "python demo.py".  This is the error message I got:
|    
|    stevenson  [1]hickey@HICKEY BOX /c/python21/s
|    $ python demo.py
|    Traceback (most recent call last):
|      File "demo.py", line 3, in ?
|        import Main
|      File "Main.py", line 15, in ?
|        from   wxPython.wx import *
|    ImportError: No module named wxPython.wx
|    
|    When I did a search of my whole Python directory, I found no file
|    named wxpython.wx.

Where did you install wxPython to?  When I installed it I put it in
d:\lib\python_packages\wxPython.  I needed to add
d:\lib\python_packages to my PYTHONPATH environment variable.  The
reason is python will look in it's install directory and PYTHONPATH to
find all modules/packages.  If you installed wxPython to a different
directory, it won't be able to find it.  You need to either include
that directory in PYTHONPATH or install it under the python directory.

The other solution is to create a .pth file in the python install
directory.  It can be named anything.  For example :

------ d:\apps\Python20\packages.pth ------
d:\lib\python_packages


That pth file will add that path to sys.path, and python will
recognize all packages in that directory (such as wxPython).


HTH,
-D