Python Error from Apress book
Dave Angel
davea at ieee.org
Tue Jul 7 11:44:44 EDT 2009
matt0177 wrote:
> Adding the python before the command line didn't work at first, but upon
> moving the files to the c:\python25 it worked like a champ. Thank you both
> for the help. Very frustrating to run into stuff like this when you're first
> trying to learn a knew language, it really throws off your momentum!
>
I'm glad you got things working. But you really shouldn't need to add
your own files to the installation directory. What you need is
straightforward, but the details are Windows specific
The following is all at the command prompt, not inside Python.
You have a PATH environment variable, with various directories on it.
Type it out using the PATH command. Pick a location on it, and add a
batch file we'll write below. It's also possible to add a new directory
to the PATH, using the control panel. Normally, the first thing I do on
a new machine is add two directories to the PATH, perhaps c:\bin and
c:\bat. The former is for the simple one-file utilities you accumulate
over the years, and the latter is for batch files. If you want to
pursue this, let me know, and I'll give details.
Now that you've picked a location for your batch file, let's create it,
calling it Python25.bat You could just call it Python.bat, but this
way, you can have more than one Python installed, and choose between them.
The contents of Python25.bat are a single line:
@c:\python25\python.exe %*
The leading @ says we don't wan the line echoed to the screen. If
you're unsure of yourself, you can leave it off till everything works
well, then add it in. The %* says to copy all the arguments you pass
the batch file into the executable.
Once this batch file is stored in your PATH, you can just type something
like:
python25 myscript.py arg1 arg2
or, to run the interpreter itself,
python25
DaveA
More information about the Python-list
mailing list