Search code examples
ubuntuvirtualenvubuntu-servervirtualenvwrapper

why does virtualenv workon not take me to the env directory


I have virtualenv setup and it is working well accept for one annoying issue. when I use the workon command to enter an environment the environment is logs in correctly but I do not get automatically directed to the environments root directory.

I have added the following lines to my .bashrc file:

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

and reloaded it (source .bashrc), but when I enter an environment I am still left in my ubuntu user home directory. I have also tries restarting my server, but still no luck.


Solution

  • I don't think workon changes to the environment directory. The solution would is to put that in postactivate file of your virtualenv.

    E.g. I have following in my <virtual_env_dir>/bin/postactivate

    cd /home/myuser/work/