How transform a python program .py in an executable program in Ubuntu?
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
What do I use on linux to make a python program executable
Just put this in the first line of your script :
#!/usr/bin/env python
Make the file executable with
chmod +x myfile.py
Execute with
./myfile.py
How to make python program .py executable?
I just want when I write the program name "executable_program" in
terminal it runs without the "./" and the ".py"
You need to do the following things:
Add the shebang at the top of your file,
#!/usr/bin/python
Make the file executable
chmod +x foo.py
Move it to somewhere that is in your
$PATH
, for example/usr/local/bin
To get rid of the .py
, simply rename the file: sudo cp foo.py /usr/local/bin/foo
burhan@sandbox:~/pytemp$ cat foo.py
#!/usr/bin/python
print('Hello World!')
burhan@sandbox:~/pytemp$ chmod +x foo.py
burhan@sandbox:~/pytemp$ sudo cp foo.py /usr/local/bin/foo
burhan@sandbox:~/pytemp$ foo
Hello World!
How can I make a Python script standalone executable to run without ANY dependency?
You can use py2exe as already answered and use Cython to convert your key .py
files in .pyc
, C compiled files, like .dll
in Windows and .so
on Linux.
It is much harder to revert than common .pyo
and .pyc
files (and also gain in performance!).
Related Topics
Running a Bash Script from Python
Crontab Failed to Run Python Script at Reboot
Python Equivalent of Ruby's 'Method_Missing'
What Is the Python Equivalent for a Case/Switch Statement
Why Does Id({}) == Id({}) and Id([]) == Id([]) in Cpython
What Should I Do with "Unexpected Indent" in Python
How to Use Phantomjs in Python
How to Enable Cors on Django Rest Framework
Python Multiprocessing + Subprocess Issues
Usb Automatic Detection in Python for Linux Env
How to Open (Read-Write) or Create a File with Truncation Allowed
Extracting Just Month and Year Separately from Pandas Datetime Column
Why Is My Pygame Application Loop Not Working Properly
Fast Punctuation Removal with Pandas