On Sep 16, 10:46 pm, Steven D'Aprano <ste...@remove.this.cybersource.com.au> wrote: > On Wed, 16 Sep 2009 21:35:21 -0700, Blaine wrote: > > bla...@attila ~/tmp $ cat ./shebang-test > > #!/usr/bin/python > > import sys > > sys.stdout.write("Hello, world.\n") > > bla...@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?
I'm not sure if there is a Ctrl+Z in here... but, here's the output: bla...@attila ~/tmp $ hexdump shebang-test 0000000 2123 752f 7273 622f 6e69 702f 7479 6f68 0000010 0a6e 6d69 6f70 7472 7320 7379 730a 7379 0000020 732e 6474 756f 2e74 7277 7469 2865 4822 0000030 6c65 6f6c 202c 6f77 6c72 2e64 6e5c 2922 0000040 000a 0000041 > If not, what happens if you run the file directly with Python? > > python shebang-test bla...@attila ~/tmp $ python shebang-test Hello, world. -- http://mail.python.org/mailman/listinfo/python-list