Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

is there a shared location for all python interpreters? I want to install a module so it becomes avaiable to all interpreters (2.6, 2.7, 3.1).

Thanks you in advance,
rubik

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

All the interpreters first look if there's an environment variable $PYTHONPATH set, which contains directories separated by :.

  • To add a directory to it, type

    export PYTHONPATH="$PYTHONPATH:/home/stefano/my_modules"
    

Everything in this directory will now be available to all of your python interpreters. Non-existent directories are ignored without an error.

If you're happy with the settings, make the change permanent by appending the export command to the .bashrc file (or any other startup file you like in your home directory.

See also:


Note: the above syntax means that the variable PYTHONPATH will contain itself and the new path, you could also remove the $PYTHONPATH: part to just set one directory. Normally, this variable will be empty on your system, it makes sense to check if there's anything in it: echo $PYTHONPATH.

share|improve this answer
1  
Thank you. It was exactly what I was searching for. –  rubik Feb 12 '11 at 15:01
add comment

Your Answer

 
discard

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.