I have a setup with a headless pi and the gravitrax bluetooth bridge.
I'd like to have a script running on boot, this script will wait for a button push.
When I push the button the program needs to connect to the gravitrax bridge, this uses a library I installed in a venv.
So my question is, how to activate the venv ?
There are many ways. Some examples all assume the venv is in $HOME/venv:
Code:
source $HOME/venv/bin/activate && python my-program.py- Use a shell swcript:
Code:
#!/bin/bashsource $HOME/venv/bin/activatepython my-program.py - Use the python interpreter in the venv directly:
Code:
$HOME/venv/bin/python my-program.py
Or is it better practise to have the venv active all the time?
No. That defeats the point of a venv
is this possible on boot?
Running A Program At Start Up A Beginner's Guide
Statistics: Posted by thagrol — Fri Feb 06, 2026 12:50 pm