Shebang doesn't work with python3

后端 未结 4 1718
执笔经年
执笔经年 2020-12-25 10:54

I have the following program:

#!/usr/local/bin/python3

print(\"Hello\")

Via terminal I do test.py and I get:

         


        
4条回答
  •  既然无缘
    2020-12-25 11:21

    You might see ImportError: No module named '_sysconfigdata_m' because /usr/lib/command-not-found is broken on your system due to the ubuntu bug.

    To workaround it, run ./test.py, not test.py -- the current directory is not in $PATH usually (due to security reasons) and therefore you should specify the path explicitly otherwise the command is not found that may lead to trying to run /usr/lib/command-not-found that results in the ImportError.

    If ./test.py fails with the same error then check that there is no '\r\v\f' (unexpected whitespace) in the shebang (print(repr(open('test.py', 'rb').readline()))). If test.py uses Windows newlines then the attempt to find '/usr/local/bin/python3\r' (notice: '\r' due to '\r\n' newline) is likely to fail that may trigger the error.

提交回复
热议问题