how would I run python script on startup (on Raspberrypi 4B, Raspi_os 64bit) within an python(3.9) environment?
I tried to just add
source envname/bin/activate
to launcher.sh
my launcher file looks like this:
cd /home/pi/thefolder
PYTHONPATH=/home/pi/.local/lib/python3.9/site-package
source envname/bin/activate
pyhton3 /home/pi/thefolder/run.py
Apparently the python3 command is not run in the env as I get an ModuleNotFoundError
for Pandas. Which is installed in the env.
EDIT1:
if I just create a new shell script with only
source envname/bin/activate
echo Hi Stackoverflow
running after chmod with sh test.sh I get the return
> test.sh 1: source: not found
> Hi Stackoverflow
while I can activate the env in the terminal
EDIT2:
Apparently Ubuntu bin/dash ist used and not bin/sh. Here is post about it
Now I have to checkout how to change it
Edit3: using :
. envname/bin/activate
echo Hi Stackoverflow
instead of
source envname/bin/activate
echo Hi Stackoverflow
seems to work. Testing in progress
---Final Edit:---
Yes it works. But important, it apparently has to be in the first line otherwise the file envname cannot be found