how do i add a new path into sys.path?

Steve Holden steve at holdenweb.com
Fri Aug 19 05:21:45 EDT 2005


James Sungjin Kim wrote:
> Steve Holden wrote:
> 
>>sys.path.append(r"C:\Temp")
> 
> 
> In this case, do I need to save the refined path, i.e, the original 
> paths + the new path (r"C:\Temp"), by using some command in order to use 
> it permanently. if yes, it would be greatly appreciated to noitce the 
> correspoding command and the usage of it.
> 
> -James

The method I outlined works only for the duration of a single program 
run, because the sys.path variable is set up each time you run the 
Python interpreter. You need to look at the suggestions you've had for 
setting the PYTHONPATH environment variable to effect changes to all 
future Python execution.

Essentially this is most usually done in the "My Computer -> Properties" 
dialog: click the "environment variables" button and create a new 
(all-users or private, depending on your needs) environment variable 
called PYTHONPATH containing a semicolon-separated list of directories 
the interpreter should add to the path.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/




More information about the Python-list mailing list