Query
Nathaniel Smith
nksmith06 at cs.earlham.edu
Tue Oct 9 11:28:05 EDT 2007
> I want to make a binary file , which would execute on it's own.
First do
$ which python
to get the location of your python binary. The default, i think, is just
/usr/bin/python.
Then add this line to the top of your file:
#!/usr/bin/python (or whatever the `which` command returned)
then finally do this command:
$ chmod +x <file>.py
This makes <file> executable ( that's what the x stands for ).
now run it with:
$ ./<file>.py
you can also trim the .py from the file and it will work just the same.
To have your script work like installed binaries, put it in a folder in your
PATH variable. For example, if you added the path /home/<you>/bin/ to your
path variable ( PATH=$PATH:/home/<you>/bin/ ) Bash would search that
directory when you typed in a command to execute. What this means is if you
rename your <file>.py to just <file> and stick it in /home/<you>/bin/ you
could just do
$ <file>
at any time to run your program.
hope my verbosity is helpful.
--
-Nate
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071009/34678548/attachment.html>
More information about the Python-list
mailing list