Reputation: 184
I'm trying run python script test.py using a virtual environment. in standard Linux bash it simply looks like
source venv/bin/activate
screen -dm python3 test.py
But how I can do the same using ansible-playbook?
Upvotes: 2
Views: 3477
Reputation: 44
When you create a virtual environment in python, a 'python3' interpreter is added in the 'bin' folder of the virtual environment (venv/bin/python3). This interpreter has all the dependencies/packages that you've installed using pip for the project.
So, if you want to execute a script using this interpreter, you can provide the complete path to the interpreter.
Example: Consider the python file: test.py Name of virtual environment: venv Command to execute the script: venv/bin/python3 test.py
Upvotes: 3