Ubuntu add directory to Python path
Ubuntu add directory to Python path
Create a .bash_profile
in your home directory. Then, add the line
PYTHONPATH=$PYTHONPATH:new_dir
EXPORT $PYTHONPATH
Or even better:
if [ -d new_dir ] ; then
PYTHONPATH=$PYTHONPATH:new_dir
fi
EXPORT $PYTHONPATH
The .bash_profile
properties are loaded every time you log in.
The source
command is useful if you dont want to log in again.
@fedorquis answer above was almost good for me, but there is at least one mistake (I am not sure about the export
statement in all caps, I am a complete newbie).
There should not be a $
sign preceding PYTHONPATH in the export statement. So the options would be:
Create a .bash_profile in your home directory. Then, add the line
PYTHONPATH=$PYTHONPATH:new_dir export PYTHONPATH
Or even better:
if [ -d new_dir ] ; then PYTHONPATH=$PYTHONPATH:new_dir fi export PYTHONPATH