Search code examples
ubuntuscriptingvirtualenvvirtualenvwrapper

How to re-run 'postactivate' script within virtualenv?


I created a virtualenv (called rpi) with a postactivate script (located in ~/virtualenvs/rpi/bin that SSH's into an RPi. When I reboot the RPi, the SSH connections closes as expected. Is there a way to run the commands in postactivate again from within the rpi virtualenv? In other words, run postactivate without running deactivate and then workon rpi.

I tried just running sudo ~/virtualenvs/rpi/bin/postactivate in the terminal, but I get command not found.


Solution

  • Run it with shell:

    sh ~/virtualenvs/rpi/bin/postactivate
    

    PS. Why sudo?