Why does Python never add itself to the Windows path?

Chris Lambacher chris at kateandchris.net
Tue Jan 2 11:43:01 EST 2007


On Sat, Dec 30, 2006 at 04:55:09PM -0800, Ben Sizer wrote:
> Martin v. L?wis wrote:
> 
> > Ben Sizer schrieb:
> > > I've installed several different versions of Python across several
> > > different versions of MS Windows, and not a single time was the Python
> > > directory or the Scripts subdirectory added to the PATH environment
> > > variable. Every time, I've had to go through and add this by hand, to
> > > have something resembling a usable Python installation. No such
> > > problems on Linux, whether it be Mandrake/Mandriva, Fedora Core, or
> > > Kubuntu. So why is the Windows install half-crippled by default?
> >
> > For several reasons:
> > 1. Python can be used just fine without being on PATH. Python
> >    scripts run fine both when double-clicked and when invoked in
> >    the command line, and if you want to use an interactive
> >    interpreter, you can find it readily on the Start menu.
> 
> Yet many scripts and applications require parameters, or to be executed
> from a certain directory. For example, setup.py. Or the various
> turbogears scripts. Or easy_install.
Martin's point was that if you need to pass arguments, you can call the script
from the command line like so:
setup.py install

The python part of the 'python setup.py install' idiom needs to be omitted on
Windows, but that does not mean that the solution is to automatically add it
to PATH.

> > 2. Many windows users (including myself) dislike setup routines that
> >    manipulate PATH.
> 
> My opinion is that this is not as big a problem as some may feel that
> it is. Unlike Unix systems, the PATH variable is rarely used. Most
> applications are launched via the Start Menu, which uses absolute
> paths, or via file associations, also done via absolute paths. The
> chance of a naming collision only really arises when you start using
> the command line, which most people don't do.
> 
> However, among those who will use the command line, are some people new
> to Python, who will come across instructions like this:
> 
> <http://docs.python.org/inst/standard-install.html>
> 
> 
> Pretty much none of the instructions in that part of the docs will work
> without you altering your path beforehand. Python's cross-platform
> nature means people rightly expect the same instructions to work on
> Linux and Windows from a standard installation. Right now, they don't.

The documentation is misleading... time for a but report:
http://sourceforge.net/tracker/index.php?func=detail&aid=1626300&group_id=5470&atid=105470

> > if Python is to be found in PATH, it
> >    should rather be installed to a directory that is known to live
> >    on PATH (or where CreateProcess searches, anyway, such
> >    as system32). So if the installer had such a feature, it should
> >    be optional, and it should default to "off".
> 
> It's a lot more anti-social to install to system32 than to modify the
> PATH variable. How easy is it to temporarily undo an installation to a
> system directory like that? What if you still want Python in your path
> but with less precedence than some other user directory?
I agree an optional add to PATH, should just add to the path rather than
install python.exe into a location on the path.
> 
> > 3. Most importantly: it is difficult to implement, and nobody has
> >    contributed code to make it work.
> 
> There appears to be a freely-available binary at this address that may
> suffice:
> http://legroom.net/modules.php?op=modload&name=Open_Source&file=index&page=software&app=modpath
Unfortunately the Python installer is not an InnoSetup installer.  If you
converted this code to Python you might get farther since the MSI could call
an add2path script with the newly installed Python executable.  I am sure
submitting a patch for the installer option would also help your cause.

-Chris



More information about the Python-list mailing list