Python Forum
Virtualenv with auto restart - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: Virtualenv with auto restart (/thread-33334.html)



Virtualenv with auto restart - JohnnyCoffee - Apr-16-2021

Is there any way to leave virtualenv in autorestart mode so that you don't have to use the (deactivate) and (activate) command to restart it ?


RE: Virtualenv with auto restart - Larz60+ - Apr-16-2021

It would be the chore of your IDE to do this.

Using VSCode, If you have selected your virtual environment as the python interpreter (ctrl-shift-P --> python:select interpreter), then whenever you select new terminal from menu, it will open with the virtual environment active.

However If I close a folder that has a terminal window in which the virtual environment has been activated, exit VSCode, and then re-start, the terminal window appears, but not with virtual environment activated. I haven't been able to figure this one out.


RE: Virtualenv with auto restart - JohnnyCoffee - Apr-27-2021

(Apr-16-2021, 08:38 PM)Larz60+ Wrote: It would be the chore of your IDE to do this.

Using VSCode, If you have selected your virtual environment as the python interpreter (ctrl-shift-P --> python:select interpreter), then whenever you select new terminal from menu, it will open with the virtual environment active.

However If I close a folder that has a terminal window in which the virtual environment has been activated, exit VSCode, and then re-start, the terminal window appears, but not with virtual environment activated. I haven't been able to figure this one out.

What I really need after deploying the application to the server is to leave virtualenv always activate (running) because as soon as I exit and close the terminal, virtualenv ends the session leaving virtualenv (off) and the application stops working ?


RE: Virtualenv with auto restart - ndc85430 - Apr-27-2021

Is it the best solution to use a virtual environment? You could run the app in a Docker container to achieve isolation.