Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1225

Python • Bookworm-start script in virtual environment after reboot

$
0
0
On older release of OS I simply run command

Code:

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
add aditional line

Code:

@lxterminal -e python3 /home/vlado/Project/main.py
And that's it, main.py was started after reboot

With Bookworm OS I have to do three steps
Line 1: moove to folder Project
Line 2: activation of the virtual environment
Line 3: start of the script main.py

Code:

vlado@raspberry:~ $ cd Projectvlado@raspberry:~/Project $ source env/bin/activate(env) vlado@raspberry:~/Project $ python main.py
When done it manual, it works normally. The question is how to do it to start script automaticaly after reboot?
I did try like below, but no luck.
Any help would be appreciated.

Code:

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
Line 4: activation of the virtual environment
Line 5: start of the script main.py

Code:

@lxpanel --profile LXDE-pi@pcmanfm --desktop --profile LXDE-pi@xscreensaver -no-splash@lxterminal -e python3 /home/vlado/Project/source env/bin/activate@lxterminal -e python3 /(env)home/vlado/Project/python main.py

Statistics: Posted by California — Tue Jan 30, 2024 5:34 am



Viewing all articles
Browse latest Browse all 1225

Trending Articles