Why virtualenv workon doesn't bring me to the env directory

I have virtualenv setup and it works well for one annoying problem. when I use the workon command to enter the environment in which the log is running correctly, but I do not automatically redirect to the root directory of the environment.

I added the following lines to my .bashrc :

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

and reload it (source .bashrc ), but when I enter the environment, I still remain in the ubuntu user home directory. I am also trying to restart my server, but still no luck.

+4
source share
2 answers

I do not think workon changing the environment directory. The solution is to put this in the postactivate file of your virtualenv.

eg. In my <virtual_env_dir>/bin/postactivate

 cd /home/myuser/work/ 
+7
source

Environments are separated from projects using virtualenvwrapper. First you need to make sure the $PROJECT_HOME variable is set. Then you can use the mkproject command to create the environment and project in `$ PROJECT_HOME '. Alternatively, you can use setvirtualenvproject to associate an existing project with an existing virtual environment.

+2
source

All Articles