Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 973
Finglish Avatar asked Aug 25 '12 10:08

Finglish


2 Answers

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/
like image 171
Rohan Avatar answered Nov 15 '22 08:11

Rohan


Environments are separate from projects with virtualenvwrapper. You first need to ensure that the $PROJECT_HOME variable is set. Then you can use the mkproject command to create an environment and a project in `$PROJECT_HOME'. Alternatively, you can use setvirtualenvproject to associate an existing project with an existing virtual environment.

like image 35
Casebash Avatar answered Nov 15 '22 06:11

Casebash