Shebang executable not found because of UTF-8 BOM (Byte Order Mark)

前端 未结 2 1363
感情败类
感情败类 2020-12-11 08:43

For some reason the shebang in one of my scripts does not work:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
print \"Hello World\"

When I

2条回答
  •  甜味超标
    2020-12-11 09:01

    The cause of the problem is that my file was encoded using UTF8 with BOM (Byte Order Mark).

    Removing the BOM, i.e. encoding the file using UTF8 without BOM solves the issue.

    NB: for Notepad++ users, "UTF8 without BOM" is also called (weirdly) "ANSI as UTF-8" in the editor.

提交回复
热议问题