RaspberryPi Autostart Python3 script with Keyboard Input?

647 Views Asked by At

I have a Python script which automatically runs on Startup. I created the Autostart by putting"

@lxterminal -e python3 /home/pi/digitale-werbetafel-py/main.py &

in

/etc/xdg/lxsession/LXDE-pi/autostart

I now want to handle user input with pythons input() function. Is there a way to do that? Because I can't type into the console and also nothing is getting printed to the console.

1

There are 1 best solutions below

2
On BEST ANSWER

The way I autostart programs in Raspbian on Raspberry pi is to add the call from the .bashrc file.

/home/your_name/.bashrc

I just tried creating a one-line script with the input() function and added this line

python3 test.py

to the end of the .bashrc file

and then accessed the pi via SSH and the program executed properly and asked for my input. The same should work if booting the pi into console mode.