[Edu-sig] What is the Best Way to use Python in the Windows Command Line

Andrew Harrington aharrin at luc.edu
Thu Dec 18 02:08:42 CET 2008

Several options, Charles.

If they typically work from a particular directory, you can have them copy
into that directory a batch file like py.cmd:

path =
start "Python Enabled Command Window"

Double clicking on it starts a console window that has Python in the path,
and any further console window you open from within it with the start
command inherit the same path.

You can omit the idlelib part if you like.

If you want the Python directories in the path generally, without diddling
with the control panel, and if your students are already downloading a few
files of yours, you might include pathman.exe from Microsoft's freely
downloadable "Windows Resource Kit" plus another batch file for them to
double click on:


pathman /au C:\Python26;c:\python26\tools\scripts;c:\python26\scripts

This changes the global path when you open a console window in the future.

If you have both 2.6 and 3.0 installed and want to go back and forth between
having them as defaults, you can have a batch file like the following and a
similar one to do the reverse.


ftype Python.CompiledFile="C:\Python26\python.exe" "%%1" %%*
ftype Python.File="C:\Python26\python.exe" "%%1" %%*
ftype Python.NoConFile="C:\Python26\pythonw.exe" "%%1" %%*
pathman /rs C:\Python30;c:\python30\tools\scripts;c:\python30\scripts
pathman /as C:\Python26;c:\python26\tools\scripts;c:\python26\scripts

The first three lines make the right behavior when selecting a file in the
GUI  Windows directory browser.
The /rs and /as in the pathman calls refer to the system path.  If for some
reason you are only manipulating the user path, use /ru and /au.

Andy Harrington

On Sat, Dec 13, 2008 at 8:59 AM, csev <csev at umich.edu> wrote:

> I teach a number of classes at the University of Michigan that are about
> Python and that use Python.    We have gone from no Python classes last year
> to five classes and four teachers that teach Python at UM.  We share intro
> documentation on how to install and set up the environment.
> One thing that really bugs me is that the WIndows Python installer does not
> add itself to the Path automatically.
> Since I insist that students can be allowed to use Mac's or PCs - I try to
> create a similar environment for both and the command line is the lowest
> common denominator.
> I end up publishing detailed documents and screen casts to get python into
> your Windows path.  It works but it is not where I want students energy
> focused in the first week of class.
> I am wondering if there is another way.
> I generally do not like IDLE - it uses a socket which can get messed up,
> bugs in the student's code seem to mess up the IDE, when a program needs to
> open a data file - it is hard to force IDLE into a known directory.
> Is there a way to use an icon and then start the icon an have the current
> working directory (i.e. to open data files) be the same directory as the
> Python file?  And then is there a way to get the output to stop at the end
> and not disappear when the program finishes?
> I do not like solutions which include adding code to the student programs
> to do things like pause before terminating or setting the current working
> directory. The students have enough trouble figuring out the 20 lines of
> code that matter let alone 5-6 lines of obtuse code to set up the
> environment.
> I can continue to teach them how to set the PATH variable in Windows - if
> anyone on this list has a suggestion - I would much appreciate it.
> Thanks.
> Charles Severance
> University of Michigan
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig

Andrew N. Harrington
 Director of Academic Programs
 Computer Science Department
 Loyola University Chicago
 512B Lewis Towers (office)
 Snail mail to Lewis Towers 416
 820 North Michigan Avenue
 Chicago, Illinois 60611

Phone: 312-915-7982
Fax:    312-915-7998
gdp at cs.luc.edu for graduate administration
upd at cs.luc.edu for undergrad administration
aharrin at luc.edu as professor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20081217/2b582e35/attachment.htm>

More information about the Edu-sig mailing list