Shebang line problems and python

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Thu Sep 17 06:46:34 CEST 2009


On Wed, 16 Sep 2009 21:35:21 -0700, Blaine wrote:

> blaine at attila ~/tmp $ cat ./shebang-test
> #!/usr/bin/python
> import sys
> sys.stdout.write("Hello, world.\n")
> blaine at attila ~/tmp $ ./shebang-test
> ./shebang-test: line 2: import: command not found ./shebang-test: line
> 3: syntax error near unexpected token `"Hello, world.\n"'
> ./shebang-test: line 3: `sys.stdout.write("Hello, world.\n")'


I've seen something similar to this, which was caused by invisible ctrl-Z 
characters somehow getting into my text file. If you view a hexdump of 
the file, are there any unexpected characters in the file, particularly 
before or between the # ! characters?

If not, what happens if you run the file directly with Python?

python shebang-test



-- 
Steven



More information about the Python-list mailing list