[Tutor] Path

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Sun, 7 Jan 2001 03:03:31 -0800 (PST)

On Sat, 6 Jan 2001, Fabrizio Cellerini wrote:

> How can I setup the Python interpreter (I am not talking about Idle
> now !) so that it searches for modules in a specific directory without
> having to enter the full path in the script (e.g. using sys.path) ?

[some text cut]

> Reading the documention, I guess I have to add paths into the PYTHONPATH
> variable or something : but can I do that ?

Yes, you'll want to include c:\my_modules within the PYTHONPATH
environmental variable.  However, adding an additional entry to your
PYTHONPATH depends on what version of Windows that you're running.  I'm
running on UNIX, so the following might not be accurate... *grin*

If you're working with Win2k, you should be able to modify environment
variables within one of the My Computer property tabs.  Look for a tab
that says "Environment Variables" or something like that.  You should see
a list of variable names, along with their values.  You'll probably need
to add a new variable named PYTHONPATH --- it'll be convenient if you set
that variable up systemwide.

If you're in Win98, things are a little simpler.  You'll probably need to
edit your autoexec.bat with the line:

SET PYTHONPATH="C:\my_modules"

After a reboot, you should be able to do those imports nicely.

> I also would like to know how to set it up so that it searches in the
> current working directory too (useful if I want to move my program and
> related modules in a different directory).

Hmmm... by default, it should search the current directory already.  
Strange!  Can you try it again?

I hope that this helps fix your problems.  Good luck!