One solution to avoid switching between Python versions every time is to create virtual environments for each service and specify the desired Python version in each virtual environment. A virtual environment is a self-contained Python environment that allows you to install packages and run scripts in isolation from other Python installations.
To create virtual environments, you can use the virtualenv package. Here is how you can create a virtual environment for each service:
Install virtualenv using the following command:
pip install virtualenv
Create a virtual environment for each service, specifying the desired Python version:
virtualenv -p /usr/bin/python3.6 walinuxagent-env
virtualenv -p /usr/bin/python3.10 netbox-env
virtualenv -p /usr/bin/python3.10 netbox-rq-env
virtualenv -p /usr/bin/python3.10 nginx-env
Activate each virtual environment before starting the corresponding service:
source walinuxagent-env/bin/activate
source netbox-env/bin/activate
source netbox-rq-env/bin/activate
source nginx-env/bin/activate
Now, each service will run with the desired Python version specified in the corresponding virtual environment, without the need to switch between Python versions every time. To deactivate the virtual environment and return to the global Python environment, you can use the deactivate command.
Note: You will need to install any required packages in each virtual environment using the pip install command.