File watcher under virtual environment


I have some file watchers that have to run under the project's virtual environment. How could I achieve that? I could not find it on the docs... :-)

Thanks in advance.



Sorry for a late reply.

Have you looked into

Could you please describe the usecase with more details?


I realise I am digging this up from the long-buried past, but hit the same issue and google steered me here.

My use case is a need to run a Django management command as a file watcher. Without the virtualenv, invoking fails. It would not be difficult to imagine other similar scenarios where a watcher needs to run a command within the current virtual env.

I can set the applicable environment variables VIRTUAL_ENV and PATH, obviously - but this is really a hacky solution that will not work on another system where different paths are used for the virtualenv etc.  Currently, I have settled on using a shell script that loads the virtual env using direnv and invoking the command, but this is just the lesser evil in available choices.

Being able to have Pycharm activate the virtual environment before executing the command would make sense in a Pycharm context.



Please sign in to leave a comment.