Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
How to make exported shell variables permanent?

Each time I set the $PYTHONPATH on my new Ubuntu server machine (old Thinkpad) and reboot, it's reset to blank.

I'm setting it like this:

export PYTHONPATH=/usr/lib/python2.7

If I ask it after that to echo $PYTHONPATH it will. And it finds modules on the path. But it loses it when I reboot. Any ideas why?

share|improve this question

marked as duplicate by Michael Mrozek Nov 13 '11 at 23:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 0 down vote accepted

Add the export command to your ~/.profile file. It will get executed every time you login. To set the value on a system wide basis, you can add it to /etc/environment.

Assuming you are using python 2.7, /usr/lib/python2.7 should be built-in. You shouldn't need to define PYTHONPATH to access modules located there. To see if it is already included try this before you set PYTHONPATH. Run python and enter these commands:

import sys
sys.path
share|improve this answer
    
Bear in mind that ~/.profile is session-wide, not system-wide. It's probably not what you want. –  Chris Down Nov 13 '11 at 23:03
    
Thank you, the information I needed was etc/environment. Still learning Unix. Thanks. –  Artur Sapek Nov 14 '11 at 0:08

Add the assignment to /etc/environment, that's what this file is designed for.

share|improve this answer
1  
Thank you, that was what I needed. –  Artur Sapek Nov 14 '11 at 0:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.