top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How do I make a Python script executable on Unix?

+3 votes
621 views
How do I make a Python script executable on Unix?
posted Nov 30, 2014 by Amit Kumar Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
 
Best answer

Just add this line at the start of the script:

#!/usr/bin/env python

and change the permission to executable using:

 chmod +x script_name.py

Now you are good to go, you can execute like,

 ./script_name.py
answer Dec 1, 2014 by Arshad Khan
Was about to answer the same, you took my points :)
:)
Ha ha, timing ;)
Similar Questions
+3 votes

I have a python script that is currently run from cron. We want to make it into a service so it can be controlled with service start/stop/restart.
Can anyone point me at site that has instructions on how to do this?

+1 vote

I have downloaded Beautiful Soup, and have followed the instruction in the 'Getting Started with Beautiful Soup' book, but my Python installations keep returning errors, so I can't get started. I have unzipped Beautiful Soup to a folder of the same name on my C drive, in accordance with the first two steps of page 12 of the aforementioned publication, but proceeding to navigate to the program as in step three, re: "Open up the command line prompt and navigate to the folder where you have unzipped the folder as follows:

cd Beautiful Soup
python setup python install "

This returns on my Python 27 :
>>> cd Beautiful Soup
File "",line 1
cd Beautiful Soup
 ^
SyntaxError: invalid syntax
>>>

also I get:
>>> cd Beautiful Soup
SyntaxError: invalid syntax
>>>

to my IDLE Python 2.7 version, same goes for the Python 3.4 installations. Hope someone can help.

+1 vote

i want to create a chrome extension. its have complex mathematical queries. so i need to use python as scripting language. help me to implement python script in google chrome addon

...