Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > how to change sys.path?

Reply
Thread Tools

how to change sys.path?

 
 
Ju Hui
Guest
Posts: n/a
 
      05-23-2006
is python search module by paths in sys.path?
how to change it manuallly?

 
Reply With Quote
 
 
 
 
bruno at modulix
Guest
Posts: n/a
 
      05-23-2006
Ju Hui wrote:
> is python search module by paths in sys.path?


sys.path is the list of path where the Python interpreter will search
modules, yes.

> how to change it manuallly?


"manually" ?-)

You mean "dynamically, by code" ? If yes, it's just a list. You can
modify it like you'd do for any other list.

Else, you may want to look at the PYTHON_PATH environnement variable.

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '(E-Mail Removed)'.split('@')])"
 
Reply With Quote
 
 
 
 
Ju Hui
Guest
Posts: n/a
 
      05-23-2006
yes, I mean I want change the sys.path value and save it for next
using.
I can change the value of sys.path, but I can't "save" it permanently.
There is no python_path environment on my pc, what the relationship
between it and the sys.path?

 
Reply With Quote
 
John Salerno
Guest
Posts: n/a
 
      05-23-2006
Ju Hui wrote:
> yes, I mean I want change the sys.path value and save it for next
> using.
> I can change the value of sys.path, but I can't "save" it permanently.
> There is no python_path environment on my pc, what the relationship
> between it and the sys.path?
>


In Windows, at least, you can create the PYTHONPATH variable and assign
to it the paths of the directories you want Python to check for when
running a script.
 
Reply With Quote
 
Jarek Zgoda
Guest
Posts: n/a
 
      05-23-2006
John Salerno napisa³(a):

>> yes, I mean I want change the sys.path value and save it for next
>> using.
>> I can change the value of sys.path, but I can't "save" it permanently.
>> There is no python_path environment on my pc, what the relationship
>> between it and the sys.path?

>
> In Windows, at least, you can create the PYTHONPATH variable and assign
> to it the paths of the directories you want Python to check for when
> running a script.


Setting Windows envvar by changing os.environ dict will work only for
processes running in the same environment (i.e. in the same shell session).

--
Jarek Zgoda
http://jpa.berlios.de/
 
Reply With Quote
 
John Salerno
Guest
Posts: n/a
 
      05-23-2006
Jarek Zgoda wrote:
> John Salerno napisa³(a):
>
>>> yes, I mean I want change the sys.path value and save it for next
>>> using.
>>> I can change the value of sys.path, but I can't "save" it permanently.
>>> There is no python_path environment on my pc, what the relationship
>>> between it and the sys.path?

>> In Windows, at least, you can create the PYTHONPATH variable and assign
>> to it the paths of the directories you want Python to check for when
>> running a script.

>
> Setting Windows envvar by changing os.environ dict will work only for
> processes running in the same environment (i.e. in the same shell session).
>


I meant actually adding the PYTHONPATH variable to the environment
variables list.
 
Reply With Quote
 
Ben Finney
Guest
Posts: n/a
 
      05-23-2006
Bruno Desthuilliers <(E-Mail Removed)> writes:

> Ju Hui a écrit :
> > what the relationship between it and the sys.path?

>
> Don't you guess ?


He's following sound Python philosophy

--
\ Hercules Grytpype-Thynne: "Well, Neddie, I'm going to be |
`\ frank." Ned Seagoon: "Right, I'll be Tom." Count Moriarty: |
_o__) "I'll be Gladys." *slap* -- The Goon Show, _World War I_ |
Ben Finney

 
Reply With Quote
 
Bruno Desthuilliers
Guest
Posts: n/a
 
      05-24-2006
Ju Hui a écrit :
> yes, I mean I want change the sys.path value and save it for next
> using.
>
> I can change the value of sys.path, but I can't "save" it permanently.

No.
> There is no python_path environment on my pc,


sorry, I meant PYTHONPATH (all caps, no underscore). Like all
environnement variable, it can be set up.

> what the relationship
> between it and the sys.path?


Don't you guess ?

 
Reply With Quote
 
Ju Hui
Guest
Posts: n/a
 
      05-24-2006
yes, we can change PYTHONPATH to add some path to sys.path value, but
how to remove item from sys.path?

 
Reply With Quote
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      05-24-2006
On Tue, 23 May 2006 20:21:10 GMT, John Salerno
<(E-Mail Removed)> declaimed the following in comp.lang.python:

> I meant actually adding the PYTHONPATH variable to the environment
> variables list.


You're looking at editing the Windows registry for that...
--
Wulfraed Dennis Lee Bieber KD6MOG
http://www.velocityreviews.com/forums/(E-Mail Removed) (E-Mail Removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (E-Mail Removed))
HTTP://www.bestiaria.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
"Change your language and you change your thoughts." Suganya C Programming 0 04-29-2008 01:35 PM
Change the master GridView after detail change? Q. John Chen ASP .Net 0 11-15-2006 05:31 PM
Change the master GridView after detail change? Q. John Chen ASP .Net 0 11-15-2006 05:30 PM
A Paradise DNS address change? What change? There was no change. Tony Neville NZ Computing 7 09-22-2006 01:02 PM



Advertisments