Saving changes to path

C

Chess Club

Hello,

I used sys.path.append() to add to the path directory, but the changes
made are not saved when I exit the compiler. Is there a way to save
it?

Thank you.
 
B

Billy Mays

Hello,

I used sys.path.append() to add to the path directory, but the changes
made are not saved when I exit the compiler. Is there a way to save
it?

Thank you.

Since python is running in a child process, it only affects its own
environment variables. I'm not sure that a process can change its
parents' environment variables in a platform independent way.


I also tried:
$ python -c 'import os; os.system("export FOO=1")'
$ echo $FOO

$

but it doesn't seem to work.
 
E

Ethan Furman

Chess said:
Hello,

I used sys.path.append() to add to the path directory, but the changes
made are not saved when I exit the compiler. Is there a way to save
it?

Do you mean saved as in your PATH environment variable is now changed?
This would be bad. Not sure about *nix, but on M$ Windows Python's
sys.path has very little in common with PATH.

Or do you mean saved as in the next time you load Python it remembers
what you had in sys.path? Not that I know of. What you can do,
however, is set your PYTHONSTARTUP environment variable to some small
..py script, which Python will run on startup, and put what you want in
there. I.e.:

8<-------------------------------------------------------------------
# Python startup file
import sys
sys.path.append('some_folder')
8<-------------------------------------------------------------------

You can change your prompts, etc.

You might also try IPython (http://ipython.scipy.org/).

~Ethan~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top