Question

I want to write a small shell script to start multiple python programs as background processes. Therefore, I plan to have the following sequence multiple times:

1. activate virtual environment
2. start python program as background process
3. deactivate virtual environment
...repeat with another program

Does the deactivation of the virtual environment affect the running process?

Was it helpful?

Solution

No. The environment as changed by virtualenv is copied for the new process and is not altered from the outside after that.

BTW, you don't need to activate a virtualenv in order to use it to start a process. It is sufficient to use the env's python interpreter (by using it's full path like /path_to_venv/bin/python)—and maybe set additional environment variables beforehand—to start your process.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top