I found the problem. The Python files contained Windows line endings ("\r\n") instead of Unix ones ("\n"). IPython was able to run them anyway but env was not, reading the shebang line as calling "python3\r". Changing the line endings to Unix style solved it. Many text editors have a command to do this, for example Geany has various options in Document / Set Line Endings.
↧