I’m new to the site, and not an experienced programmer. I am trying to install a text aligner to my mac (leopard version 10.5.8). I have used the program before on other computers without difficulty. It requires the installation of XCode (done), SOX (done) and HTK (done). However, after navigating to the appropriate folder, I enter the command:
$ ./align.py
and this error pops up:
Unknown option: -B
usage: /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
So I type:
$ python -h
which gives me a list of options, including:
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
Like I said, I’m pretty green to the world of programming, and so I’m not sure what to do with this information or how to fix the problem. I tried updating python, even though my previous version (2.5.1) should have worked. I now have 2.7.3 installed. Any advice would be much appreciated!!!
The first line of an executable script is called the “she-bang”. It tells the shell which interpreter to use to run the following code.
The reason it was breaking by running ./align.py is because when you use that form, you tell it to execute using whatever is specified in that very first line:
This says to use a python located specifically at this location. Usually you do not want an explicit path as it can cause problems (as it did for you) if that is not the appropriate python on your system. The better way, unless you have some specific needs, is to allow it to use whatever python your own environment resolves:
It worked when you ran: “python align.py”, because now you are bypassing the shebang line, and calling your own python with the script as the first argument. This runs it directly.
I assume the first line of your script contains a shebang pointing at a wrong python and includes the -B flag.