Possible Duplicate:
Calling a python script from command line without typing “python” first
I've tried
bash$ chmod +x script.py
doesn't work. I also remember to put
#!usr/bin/env python
at the beginning of the script.
bash$ ./script.py
Does nothing, it just changes my cursor to a cross lol
UPDATE: I've fixed
#!/usr/bin/python
i've also tried
chmod a+x script.py
still nothing. My script has import commands and uses sys.argv...I've followed the instruction on this link (look at the end of the page). Nothing works
Underneath the GUI is PyInstaller, a terminal based application to create Python executables for Windows, Mac and Linux. Veteran Pythonistas will be familiar with how PyInstaller works, but with auto-py-to-exe any user can easily create a single Python executable for their system.
On Windows, the standard Python installer already associates the . py extension with a file type (Python. File) and gives that file type an open command that runs the interpreter ( D:\Program Files\Python\python.exe "%1" %* ). This is enough to make scripts executable from the command prompt as 'foo.py'.
It can run a Python code in two ways: As a Script or Module. As a piece of code written in an interactive session.
the "shebang" needs to contain the full path to the executable. You're calling env
, which is good, but you haven't given it the full path: start your script like so:
#!/usr/bin/env python
# ^
Here is the list of things to try, in rough order of likelihood:
#!/usr/bin/python
)./usr/bin/python
actually exists and works. Your Python interpreter may be installed elsewhere. Type /usr/bin/python
at a prompt and make sure Python starts. Type which python
if you don't know where it is installed..
is not in your PATH
(it may not be), you must run your script with ./script.py
because the shell does not look for commands in the current directory by default.+x
, verify with ls -l
).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With