问题
I'm using virtualenvwrapper-win and want to use the postactivate hook of virtualenvwrapper to set environment variables. However it seems virtualenvwrapper-win doesn't include a postactivate file, and I haven't been able to get it to work by creating my own. Does anybody know how to get the postactivate hook to work with virtualenvwrapper-win?
I want to include this in postactivate to set an environment variable: SET APP_SETTINGS="example.setting"
回答1:
I actually solved it myself. You can put any environment variables in the activate.bat file in the Scripts folder of your virtualenv.
回答2:
If you have already defined your VIRTUALENVWRAPPER_HOOK_DIR
variable, just add this line to workon.bat
.
call "%VIRTUALENVWRAPPER_HOOK_DIR%\postactivate.bat"
Just make sure you put it above :END
来源:https://stackoverflow.com/questions/27536538/where-to-define-the-postactivate-hook-with-virtualenvwrapper-win