0

I have edited ~/.config/lxsession/LXDE-pi/autostart using nano (without sudo) to open a lxterminal and run a simple python script that contains an infinite while loop with a print statement.

In my autostart file I have the following command:

@lxterminal -e python3 ~/Desktop/t.py

However, whenever I boot into Desktop environment, I see a lxterminal window pop up for a split second then disappear.

When I also add @lxterminal -e python3 -v into the autostart file, it runs perfectly and the lxterminal window stays there.

I have changed t.py to have one line: print('hello'). The result is the same. A terminal window will open for a split second then close. I don't believe a print statement should cause an exception.

Does anyone know what could be causing my issue?

Thanks

  • change the t.py so that it will run without error in python 2.7 and try rebooting – jsotola Nov 12 '18 at 7:43
  • 2
    Possible duplicate of LXDE autostart is not working – Dirk Nov 12 '18 at 9:18
  • I have changed t.py to have one line: print('hello'). The result is the same. A terminal window will open for a split second then close. I don't believe a print statement should cause an exception. – jgv115 Nov 13 '18 at 6:38
  • Post your code. Maybe your infinite loop is not as infinite as you think. – Dmitry Grigoryev Nov 15 '18 at 8:17
1

With lxterminal -e python3 you are starting the python3 interpreter and it prompts you with >>>. It is still running until you quit it with <Ctrl>D. Then the lxterminal will also close. Your hello script just prints it and terminates and with it also lxterminal. That is what you see but it is too short to realize the hello output. For testing make your t.py as following:

from time import sleep
print('hello world')
while True:
    sleep(60)

with the endless while loop the script does not terminate and will stay in lxterminal until you interrupt it with <Ctrl>C. Then lxterminal also closes.

  • The OP claims that they have an "infinite while loop with a print statement". In my understanding, an infinite loop cannot be too short. – Dmitry Grigoryev Nov 15 '18 at 8:15
  • @DmitryGrigoryev I refer to the comment only using print('hello'). You have already commented it. I have edit the question and add the comment to clarify this. – Ingo Nov 15 '18 at 9:07
0

Edit the local autostart file:

sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart

Add the following with full paths to python3 and your code:

@lxterminal -e /usr/bin/python3 /home/pi/Desktop/t.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.