Young-Jin Lee wrote:
Import Error: No module named wxPython.wx
My $PATH has
/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/lib/python2.2/Tools/idle
and my $PYTHONPATH has no entry.
What should I do if I want to run wxPython demo files?
It looks likeyour problem is with your wxPython installation. If you
installed wxPython form the rpms, it should be done right, but who
knows. did you install it at all?
to check:
first, start up a python interpreter:
python2 (make sure it is version 2.2 that is starting)
type the import line at the command line:
from wxPython.wx import *
This is how it is usually imported. If this works, then there is
something wierd with the demo! If it fails, look to see where wxPython installed:
you should have a directory:
/usr/local/lib/python2.2/site-packages/wxPython
if not, wxPython is not installed. If so, it should have in it a whole
bunch of *.py and *.pyc files, including wx.py, which is what you are
trying to import.
if all that is there, perhpaps you Python Path is not right, although I
can't imagine how that would happen. At the Python prompt, type:
import sys
sys.path
/usr/local/lib/python2.2/site-packages
should be in there.
After all that. I am out of ideas!
NOTE: I'm running Python 2.1, so I may have some of the paths wrong, but
I'm pretty sure it hasn't changed.
The other question I want to ask is "double-clicking python file" didn't
work on my RedHat. As far as I understand, it should work because the first
line, #!/usr/bin/env python, in every python source code, but it didn't
work.
How can I run them by double-clicking?
How you invoke a Python script from a GUI is dependent on the GUI. With
RedHat, you are probably running KDE or GNOME. Check out their docs to
see how you make something an application. One issue is that you don't
neccesarily want every *.py file run when you click on it. In general,
it's probably more common that I would want to open it in my editor, for
instance. In KDE, if you right-click on a file, you can select "open
with" and get a choice of applications to open it with. If you choose
(or typoe in) python2, then it should run. Note that if it is a console
application, you need to check the "run in terminal" option so that you
will get a terminal for input/output.
Also, in order for a file on *nix (of any kind) to be seen as an
executable, you need to set the executable permisions. Try:
chmod a+x myscript.py
Having done that, you can invoke the script on the command line by
typing it's name (with path, inclucing "./" if it is in your working
directory) if you put it on your $PATH, say in /usr/local/bin, you will
be able to run it from anywhere by typing it's name.
Have fun,
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov