Postactivate doesn't work

624 views
Skip to first unread message

Sergio Rus

unread,
Sep 12, 2015, 2:28:16 PM9/12/15
to virtualenvwrapper
Hello everybody,

I can't have the postactivate script working in my laptop. I have been trying to solve the issue by myself for several months, but I can't find any solution. I have tried uninstalling and installing again...

I'm using virtualenvwrapper in two computers (PC and laptop), both using the same operating system (Ubuntu 12.04), the same .bashrc and the same version of Python, Pip, virtualenv and virtualenvwrapper (both packages installed with Pip). I have inspected the common global variables both for virtualenv and virtualenvwrapper and seems to be ok. So I think I'm missing something...

It seems like virtualenvwrapper is not sourcing the postactivate script (I use local postactivate scripts for every virtualenv project), because if I source it manually, it works. 

Any ideas, please?

Thanks!

Doug Hellmann

unread,
Sep 12, 2015, 2:29:51 PM9/12/15
to virtuale...@googlegroups.com
Did you install from a .deb file or using pip?

What is the path to the postactivate file within the virtualenv?

What permissions are on the file?

Do you get an error, or does it just not do anything at all?

Doug

Sergio Rus

unread,
Sep 12, 2015, 5:58:27 PM9/12/15
to virtualenvwrapper
Thank you very much for the quick reply. Please, see my answers inline:

Did you install from a .deb file or using pip?

I installed them with Pip, both virtualenv and virtualenvwrapper. They are located in /usr/local.

What is the path to the postactivate file within the virtualenv?

This is what I get after running workon on a dummy project:

$ echo $VIRTUAL_ENV/bin/postactivate
/home/sergio/.virtualenvs/foobar/bin/postactivate

What permissions are on the file?

$ ls -l $VIRTUAL_ENV/bin/postactivate 
-rw-rwxr-x 1 sergio sergio 385 Sep 12 18:44 /home/sergio/.virtualenvs/foobar/bin/postactivate

Do you get an error, or does it just not do anything at all?

It just not do anything at all. But it works if I source the postactivate script manually.

Another important issue is that the postactivate script is not automatically created when I run mkvirtualenv.
This is what I get if I list the virtualenv folder just after a fresh mkvirtualenv:

$ ls -l ~/.virtualenvs/foobar/bin
total 2964
-rw-rw-r-- 1 sergio sergio    2243 Sep 12 22:46 activate
-rw-rw-r-- 1 sergio sergio    1269 Sep 12 22:46 activate.csh
-rw-rw-r-- 1 sergio sergio    2482 Sep 12 22:46 activate.fish
-rw-rw-r-- 1 sergio sergio    1137 Sep 12 22:46 activate_this.py
-rwxrwxr-x 1 sergio sergio     260 Sep 12 22:46 easy_install
-rwxrwxr-x 1 sergio sergio     260 Sep 12 22:46 easy_install-2.7
-rwxrwxr-x 1 sergio sergio     232 Sep 12 22:46 pip
-rwxrwxr-x 1 sergio sergio     232 Sep 12 22:46 pip2
-rwxrwxr-x 1 sergio sergio     232 Sep 12 22:46 pip2.7
-rwxrwxr-x 1 sergio sergio 2993544 Sep 12 22:46 python
lrwxrwxrwx 1 sergio sergio       6 Sep 12 22:46 python2 -> python
lrwxrwxrwx 1 sergio sergio       6 Sep 12 22:46 python2.7 -> python
-rwxrwxr-x 1 sergio sergio     239 Sep 12 22:46 wheel

As you can see, some files are not automatically created. If I compare this folder with the one created in my other computer (where postactivate works fine), the missing files are:

get_env_details
postactivate
postdeactivate
preactivate
predeactivate

Any ideas?
As I said, I tried uninstalling and installing again both virtualenv and virtualenvwrapper... It's a really weird issue!

Thanks

Doug Hellmann

unread,
Sep 13, 2015, 8:15:49 AM9/13/15
to virtuale...@googlegroups.com
It would be useful to see what the hook program is doing when it runs. In the course of trying to reproduce the problem, I discovered that the logging configuration in the hook loader is wrong, so I’ve pushed a patch for that.

Can you install the latest virtualenvwrapper from the git repo (g...@bitbucket.org:dhellmann/virtualenvwrapper.git) and then run these shell commands and put the output in an email or pastebin?

export HOOK_VERBOSE_OPTION=-v
set -x
mktmpenv
deactivate
set +x



--
You received this message because you are subscribed to the Google Groups "virtualenvwrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to virtualenvwrap...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sergio Rus

unread,
Sep 13, 2015, 8:37:47 AM9/13/15
to virtuale...@googlegroups.com

--
You received this message because you are subscribed to a topic in the Google Groups "virtualenvwrapper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/virtualenvwrapper/ZMfM04CVW3g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to virtualenvwrap...@googlegroups.com.

Sergio Rus

unread,
Sep 13, 2015, 8:58:27 AM9/13/15
to virtuale...@googlegroups.com
So it seems that now those missing files are created. And postactivate is working again:

$ mkvirtualenv foobar
New python executable in foobar/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/sergio/.virtualenvs/foobar/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/sergio/.virtualenvs/foobar/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/sergio/.virtualenvs/foobar/bin/preactivate
virtualenvwrapper.user_scripts creating /home/sergio/.virtualenvs/foobar/bin/postactivate
virtualenvwrapper.user_scripts creating /home/sergio/.virtualenvs/foobar/bin/get_env_details

$ ll /home/sergio/.virtualenvs/foobar/bin
total 2992
drwxrwxr-x 2 sergio sergio    4096 Sep 13 13:55 ./
drwxrwxr-x 6 sergio sergio    4096 Sep 13 13:55 ../
-rw-rw-r-- 1 sergio sergio    2243 Sep 13 13:55 activate
-rw-rw-r-- 1 sergio sergio    1269 Sep 13 13:55 activate.csh
-rw-rw-r-- 1 sergio sergio    2482 Sep 13 13:55 activate.fish
-rw-rw-r-- 1 sergio sergio    1137 Sep 13 13:55 activate_this.py
-rwxrwxr-x 1 sergio sergio     260 Sep 13 13:55 easy_install*
-rwxrwxr-x 1 sergio sergio     260 Sep 13 13:55 easy_install-2.7*
-rwxr-xr-x 1 sergio sergio     150 Sep 13 13:55 get_env_details*
-rwxrwxr-x 1 sergio sergio     232 Sep 13 13:55 pip*
-rwxrwxr-x 1 sergio sergio     232 Sep 13 13:55 pip2*
-rwxrwxr-x 1 sergio sergio     232 Sep 13 13:55 pip2.7*
-rw-r--r-- 1 sergio sergio      72 Sep 13 13:55 postactivate
-rw-r--r-- 1 sergio sergio      74 Sep 13 13:55 postdeactivate
-rwxr-xr-x 1 sergio sergio      69 Sep 13 13:55 preactivate*
-rw-r--r-- 1 sergio sergio      75 Sep 13 13:55 predeactivate
-rwxrwxr-x 1 sergio sergio 2993544 Sep 13 13:55 python*
lrwxrwxrwx 1 sergio sergio       6 Sep 13 13:55 python2 -> python*
lrwxrwxrwx 1 sergio sergio       6 Sep 13 13:55 python2.7 -> python*
-rwxrwxr-x 1 sergio sergio     239 Sep 13 13:55 wheel*

Doug Hellmann

unread,
Sep 13, 2015, 9:00:54 AM9/13/15
to virtuale...@googlegroups.com
That seems to show the postactivate script being created (https://gist.github.com/srus/fa4470ef60365a6e9a43#file-virtualenvwrapper-4-7-1-dev3-test-log-L96) and then run (https://gist.github.com/srus/fa4470ef60365a6e9a43#file-virtualenvwrapper-4-7-1-dev3-test-log-L320).

I didn’t ask what version of virtualenvwrapper you were running before installing from git, do you remember?

Doug

Sergio Rus

unread,
Sep 13, 2015, 9:05:54 AM9/13/15
to virtuale...@googlegroups.com
I guess the latest version. I installed it with: pip install -U virtualenvwrapper

I didn't have any other virtualenwrapper installed on the system (I mean I didn't use the Linux repositories).


Sergio Rus

unread,
Sep 14, 2015, 6:56:15 AM9/14/15
to virtuale...@googlegroups.com
I've just installed the new version (4.7.1) from PyPi and now everything works perfect. Thank you very much!!

Benedikt Breinbauer

unread,
Mar 29, 2016, 4:52:53 AM3/29/16
to virtualenvwrapper
Hi,

I have a similar setup (Ubuntu 12.04) and the same problem, postactivate not working and the hook scripts not being created automatically with a new virtualenv.

I'm using virtualenvwrapper 4.7.1 (2015-09-13) and virtualenv 15.0.1. (2016-03-17) and just recently upgraded both (sorry can't remember from which version, certainly more than a year old).
Could it be that the relatively new virtualenv version is not compatible anymore?

Thanks for any help!

Benedikt
Reply all
Reply to author
Forward
0 new messages