subprocess.Popen(): OSError: [Errno 8] Exec format error in python?

前端 未结 7 2098
余生分开走
余生分开走 2020-12-06 09:07

Yesterday, I wrote and ran a python script which executes a shell using subprocess.Popen(command.split()) where command is string whic

7条回答
  •  天命终不由人
    2020-12-06 09:26

    As @tripleee said, there is an issue executing your script. Make sure:

    • Change the shell command to "./my_path/my_script.sh" or "/bin/bash my_path/my_script.sh". Account for environment variables, if necessary.
    • Both scripts have execute bit set (chmod +x)
    • The files exist at the location you think they do. (Use abspath or verify environment)
    • The files have contents
    • Try removing and re-typing the first line. I recommend killing the whole line, and hitting backspace several times in case there's a non-printable character before the #!

    See also: Why is '#!/usr/bin/env python' supposedly more correct than just '#!/usr/bin/python'?

提交回复
热议问题