Search code examples
python-3.xraspberry-piautostartraspbian-buster

RaspberryPi Autostart Python3 script with Keyboard Input?


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.


Solution

  • 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.