I want to permanently add a path to $PYTHONPATH. According to this SO answer, adding
export PYTHONPATH="${PYTHONPATH}:/my/other/path"
to the .bashrc
file should accomplish this on a Mac or GNU/Linux distro. However, on my system, $PYTHONPATH
is empty, so after doing the export, if I echo $PYTHONPATH
, it returns :/my/other/path
-
which is not a valid path because of the prefixed :
. One way around this is to do
export PYTHONPATH="/my/other/path"
but that would clobber other paths if they do exist on different machines. How can I handle both cases?