1

I have a python script which looks like this:

#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

import ...

And can normally execute it with python3 script.py but can't do so doing this: ./script.py. The script is executable (755), has the correct character encoding and is in unix style (LF instead of CRLF).

When I run /usr/bin/env python3 I get dropped into the python shell interpreter.

When executing the python script from bash the interpreter (for the script) is bash, when executing it from zsh the interpreter is sh.

It doesn't matter if I change the shebang to any of the following variants:

#!/usr/bin/python3
#!/usr/bin/env python
etc...

Has anyone any ideas?

redxef
  • 492
  • 4
  • 12
  • 5
    Dump the first few bytes as hex. It's not unheard of for editors (especially Windows-y editors) to put a BOM on UTF-8 text, [which breaks shebangs](https://stackoverflow.com/q/19065522/364696). – ShadowRanger Jul 02 '20 at 00:48
  • Please provide the run log including any errors. That may give people more of a clue. – kaylum Jul 02 '20 at 00:50
  • @ShadowRanger that fixed it, thanks, never would've thought of that. I guess I also wouldn't have thought about looking at a hex dump. – redxef Jul 02 '20 at 00:57

0 Answers0