EDIT: Works for root, sudo is the problem. Read below.
I have a directory with my own libraries, e.g. my Python libraries are located at /home/name/lib/py.
I've added this directory to Python's PATH for all users (including root) by adding the following line to /etc/bash.bashrc:
export PYTHONPATH=$PYTHONPATH:/home/name/lib/py
It works for all users (including root). But it doesn't work for sudo. Is there any way I can make sudo use /etc/bash.bashrc?
EDIT: More information:
I've added PYTHONPATH to sudoers file like so: Defaults env_keep += "HOME PYTHONPATH". It sitll doesn't work.
env | grep PYTHON:
PYTHONDONTWRITEBYTECODE=1
PYTHONPATH=/home/name/lib/py
sudo env | grep PYTHON:
PYTHONDONTWRITEBYTECODE=1
sudo echo $PYTHONPATH:
/home/name/lib/py
sudoand not anything Python specific, this would probably get more useful answers on SU as mentioned, or on unix.stackexchange.com. – agf Nov 1 '11 at 18:19