PYTHONPATH & Win 98 - seems broken

Steve Holden sholden at holdenweb.com
Tue Sep 5 15:40:22 CEST 2000


The sad fact appears to be that the interpreter does not use the
PYTHONPATH variable when looking for the file named on the command
line, only for modules referred to by "from" and "import" statements.

In the UNIX environment you can just make your python script executable,
then you can use the script name as long as it's in a directory on your
PATH.

You can do a similar thing in Windows NT (and, I believe, W2K, but I am
not yet fighting that particular OS).  This involves setting registry
values to associate the ".py" extension with the interpreter.

Windows 95 and 98 lose here, as there doesn't appear to be a way to
associate arbitrary filename extensions with particular interpreters.

regards
 Steve


Mitchell Timin wrote:
> 
> Thanks for trying to help, but:
> 
> Kevin Cazabon wrote:
> 
> > Well, it doesn't do any good that your PYTHONPATH is set to include the
> > directory that your prog.py file is in... it's not PYTHON that is
> > interpreting your command, it's DOS.
> 
> I don't think so.  DOS interprets the "python" part of the command, and then
> passes the rest of the command line to python.exe.
> 
> > If you set your DOS "Path" to include the directory, it will work.  you can
> > do this by typing:
> >
> > PATH=%%PATH%%;"c:\My Documents"
> 
> I tried it; doesn't work.  (because path is only used to find python.exe)
> 
> > You could also type:
> > python -c "import prog"
> 
> Also doesn't work.
> 
> > or:
> >
> > python "c:\my documents\prog.py"
> 
> This works, but it would be more convenient if PYTHONPATH would work like its
> supposed to.
> 
> >
> >
> > Kevin.
> >
> > "Mitchell Timin" <timin at home.com> wrote in message
> > news:39A088F0.FFD14445 at home.com...
> > | Admittedly, I'm a newbie, but it seems clear enough that the PYTHONPATH
> > | variable should let me access a .py file in a different directory.
> > details:
> > |
> > | I'm working in a DOS window.  PYTHONPATH is set to:
> > | c:\"my documents"\python.  In that directory is a file prog.py.  My
> > current
> > | directory is c:\Python16.  I type: python prog.py, and I get the message
> > | "can't open file 'prog.py'.
> > |
> > | ?
> > |
> > | Thanks in advance,
> > |
> > | m
> > |

-- 
Helping people meet their information needs with training and technology.
703 967 0887      sholden at bellatlantic.net      http://www.holdenweb.com/



More information about the Python-list mailing list