Saturday, May 14, 2022

[FIXED] How transform a python program .py in an executable program in Ubuntu?

Issue

I have a simple python program and I want an executable version (for Ubuntu Linux) of this program to avoid running it in the terminal with python myprogram.py.

How can I do that ?


Solution

There is no need to. You can mark the file as executable using

chmod +x filename

Make sure it has a shebang line in the first line:

#!/usr/bin/env python

And your linux should be able to understand that this file must be interpreted with python. It can then be 'executed' as

./myprogram.py


Answered By - relet
Answer Checked By - Terry (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.