0

I updated my PYTHONPATH variable in bash_profile

But changes take place when I reboot the machine.

Why?? Is there any better solution to this??

2 Answers2

0

Permanently add a directory to PYTHONPATH

Community
  • 1
  • 1
FreshDink
  • 27
  • 6
0

The recommended solution is to use virtualenv and even better with virtualenvwrapper

virtualenv/virtualenvwrapper Quick Start:

pip install virtualenvwrapper
source $(which virtualenvwrapper.sh)

mkvirtualenv foo

workon foo

Note: For Python 3.x users; Python 3.x now comes with venv

However putting an environment variable in your $HOME/.bash_profile typically only gets executed/evaluated once per login session (you don't really need to rebot as such).

Typically in Bash this means:

bash -l  # enter a new login session

However if you want the environment variable everywhere without having to start a new "login session" you should put it in $HOME/.bashrc.

Example:

echo -e "export PYTHONPATH=\$HOME/lib/python\n" >> $HOME/.bashrc
James Mills
  • 17,096
  • 3
  • 41
  • 56