I'm designing a GUI for my Raspberry Pi 3 B+. I've written the code in Python3.5 and now I want my script to be run as executable (Raspbian package).

Is it possible to do so and if possible any solution is welcomed.

  • 2
    your question has nothing to do with the Raspberry Pi .... it is a Linux question – jsotola Aug 1 '19 at 15:10

Your question is ambiguous.

If what you want is to execute the python script at the command line add the shebang at the start of the script and mark it as executable.

#! /usr/bin/env python3

You can rename the script (omit the .py extension if desired).

If you want any user to be able to execute the script you need to put it in a directory on the path e.g. /usr/local/bin and ensure that all users have execute permission with sudo chmod +x scriptname

The script will remain a normal python program which can be examined by anyone with read permission.

If you want to convert to a compiled executable this can be done with some tools - this is a general Linux problem, not specific to the Pi.

Making a program executable from the GUI menu requires constructing a suitable LXDE desktop shortcut script.desktop. It is not easy to give generic instructions, but there are plenty of tutorials.

  • I've followed the same process but it still not working. – Vikash Sharma Aug 2 '19 at 4:41
  • 1
    @VikashSharma "followed the same process" is unhelpful - actually list in your question what YOU did including the script – Milliways Aug 2 '19 at 5:57

Put the following line at the start of your script.

#!/usr/bin/env python

Make the script executable.

chmod +x script.py

  • The same is not executing for me – Vikash Sharma Aug 1 '19 at 12:32
  • @VikashSharma You have done something wrong. – joan Aug 1 '19 at 13:26
  • @VikashSharma What error message do you get if you try to run /full/path/to/my/script.py from the command line? – Ingo Aug 1 '19 at 15:20
  • I get no error, instead of the script doesn't work – Vikash Sharma Aug 2 '19 at 4:41
  • Pass the popcorn... – Michael Harvey Aug 3 '19 at 10:14

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.