Using PythonPath under Windows Vista.

Steve Holden steve at holdenweb.com
Sun Jan 4 14:55:52 CET 2009


Morgul Banner Bearer wrote:
> Hi Everybody,
> 
> I was using the O'Reilly book from 1999 to look into Python and ran
> into a problem with
> the use of Pythonpath.
> 
> I have Python installed under c:\python26.
> I have the module "Brian.py" that i want to run installed under c
> \python26\work
> 
> In Windows Vista, I have set an environment variable "Pythonpath"
> equal to c:\python26\work
> (by using the "My computer", "Properties", "Advanced", "Environment
> Variables".
> 
> The behaviour of the program is as follows :
> In a Dos Box, the program executes nicely when i type :
> "c\python26>python c:\python26\work\brian.py".
> 
> Now i understand that- because I set the Pythonpath- the program
> should also run if i type:
> "c\python26>python brian.py"
> (under these conditions Python should look for the file brian.py in
> the folders specified in the
> Pythonpath).  However, this does not work, but gives : "Can't open
> file... No such file or directory".
> 
The PYTHONPATH variable is used by the interpreter to augment the set of
locations to search for *imported* modules. It isn't used in locating
the script from the command line. However, you might find that your
installation has set .py up to be executed by the Python interpreter
using the pathext mechanism, in which case you can just give the
script's name and it will be found if it's somewwhere on your PATH (not
your PYTHONPATH).

> I have not found further info availlable on bulletin boards on the
> internet, so if anybody can post
> the solution here, that would help me out.
> 
Well, you could have tried the FAQ, but I don't know off the top of my
head whether that explains things.  [Pauses to re-read
http://www.python.org/doc/faq/windows/]. Well, some useful things are
covered there, but it doesn't answer your question.

Since the -m option runs the code of a module you will probably find that

  python -m brian

will do what you expect.

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list