简体   繁体   中英

Relative Python Path to Script

Python project looks like this:

setup.py
README
Application
    scripts
        hello.py
    shell_scripts
        date.sh

From hello.py I'm executing the command subprocess.call(['../shell_scripts/date.sh']) and receiving the error OSError: [Errno 8] Exec format error .

Note: date.sh is a perfectly valid shell script and is executable. I've also tried os.path.realpath to no avail.

I assume this is due to an invalid path?

Exec format error will come when the shell isn't set at the script. try adding #!/bin/sh at the beginning of the script and execute the python script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM