Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a Python script that I want to be started on boot. Putting a command in rc.local attempts to run the script, but fails because the script can't find the libraries on which it depends. These libraries are in a non-standard location. Normally, this isn't a problem because I specify these locations by setting up the PYTHONPATH environment variable in /etc/environment.

I tried specifying PYTHONPATH in rc.local (a non-optimal solution anyway because I'd like to specify it system-wide for all users in one place, ie, /etc/environment) which partly cures the problem. But it's still failing for one library (Quick2Wire) where the included file is in a sub-dir. PYTHONPATH includes the path:


The actualy include file is:


Normally, Python has no problem knowing it needs to look in the quick2wire sub-dir.

I guess I can setup a special version of PYTHONPATH in rc.local just to get this script to run and then have the version in /etc/environment replace it. Just wondered if there's a more elegant solution.

share|improve this question
Have you considered using a virtualenv? – Salem Nov 5 '12 at 20:40
export PYTHONPATH=</blah/blah> ; python /usr/local/lib/cr/python/quick2wire-python-api/src/quick2wire/ 

the above should do the trick.

Else you can create a script ( .sh ) with above content and call the script from rc.local ;)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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