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

Python • Autostart main.py in venv

$
0
0
Hello, I have RPi-4 with latest 64bit Bookworm OS (full), X11 desktop.
I manged to do all necessary things to run main.py manually.

First step was to create file StartMain.sh in the same folder where main.py is located.

Code:

sudo nano /home/vlado/Project/StartMain.sh
StartMain.sh

Code:

#!/bin/bashcd /home/vlado/Projectsource env/bin/activatepython main.py
In terminal I can manually start my app like below

Code:

vlado@raspberry:~ $ cd Projectvlado@raspberry:~/Project $ sudo chmod +x StartMain.shvlado@raspberry:~/Project $ ./StartMain.sh start
So, the question is how to start main.py automatically at restart of the RPi-4?

With best regards, Vlado

Statistics: Posted by California — Sat May 03, 2025 3:42 pm



Viewing all articles
Browse latest Browse all 1584

Trending Articles