12.07.2015 Views

Is Python a

Is Python a

Is Python a

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

These variables are straightforward to use, but here are a few pointers:• The PATH setting lists a set of directories that the operating system searches forexecutable programs. It should normally include the directory where your<strong>Python</strong> interpreter lives (the python program on Unix, or the python.exe file onWindows).You don’t need to set this variable at all if you are willing to work in the directorywhere <strong>Python</strong> resides, or type the full path to <strong>Python</strong> in command lines. OnWindows, for instance, the PATH is irrelevant if you run a cd C:\<strong>Python</strong>25 beforerunning any code (to change to the directory where <strong>Python</strong> lives), or always typeC:\<strong>Python</strong>25\python instead of just python (giving a full path). Also, note thatPATH settings are mostly for launching programs from command lines; they areusually irrelevant when launching via icon clicks and IDEs.• The PYTHONPATH setting serves a role similar to PATH: the <strong>Python</strong> interpreter consultsthe PYTHONPATH variable to locate module files when you import them in aprogram. (For more on the module search path, refer to Chapter 18.) If used,this variable is set to a platform-dependent list of directory names, separated bycolons on Unix, and semicolons on Windows. This list normally includes justyour own source code directories.You don’t need to set this variable unless you will be performing cross-directoryimports—because <strong>Python</strong> always searches the home directory of the program’stop-level file automatically, this setting is required only if a module needs toimport another module that lives in a different directory. As mentioned inChapter 18, .pth files are a recent alternative to PYTHONPATH.• If PYTHONSTARTUP is set to the pathname of a file of <strong>Python</strong> code, <strong>Python</strong> executesthe file’s code automatically whenever you start the interactive interpreter, asthough you had typed it at the interactive command line. This is a rarely usedbut handy way to make sure you always load certain utilities when workinginteractively; it saves an import.• If you wish to use the Tkinter GUI toolkit, you might have to set the two GUIvariables in Table A-1 to the names of the source library directories of the Tcland Tk systems (much like PYTHONPATH). However, these settings are not requiredon Windows systems (where Tkinter support is installed alongside <strong>Python</strong>), andare usually not required elsewhere if Tcl and Tk reside in standard directories.Note that because these environment settings (as well as .pth files) are external to<strong>Python</strong> itself, when you set them is usually irrelevant. They may be set before or after<strong>Python</strong> is installed, as long as they are set the way you require before <strong>Python</strong> is actuallyrun.Configuring <strong>Python</strong> | 643

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!