How do I activate a virtual enviroment on Armbian at startup?

220 views Asked by At

I need to activate a virtualenv Python enviroment on my NanoPI NEO with Armbian (Debian-based). I created a simple script to do so:

#!/bin/bash
echo "Activating application's virtual enviroment..."
source /mpoint/bin/activate
echo "Running main app.."
python /mpoint/mpoint.py

I chmodded all the necessary files, and copied the mentioned script to init.d and update-rc.d'd it.

Problem is, from what I understand I need to run that script as source, that is the script creates its own instance with the enviroment, then closes. Other questions mention various solutions, but none of them answer my question - how can I run this as source at startup?

1

There are 1 answers

1
sinoroc On

It could be that you don't have to activate the virtual environment at all. Generally one only needs to call the Python interpreter in the virtual environment's bin directory explicitly. In your case the following should be good enough: /mpoint/bin/python /mpoint/mpoint.py.