OSError: [Errno 8] Exec format error when calling subprocess.Popen on an exe file
Question:
I’m calling subprocess.Popen
on an exe
file in this script, and it throws:
OSError: [Errno 8] Exec format error: ‘/Users/maxghenis/PolicyEngine/openfisca-us/openfisca_us/tools/dev/taxsim/taxsim35.exe’
The answer to subprocess.Popen(): OSError: [Errno 8] Exec format error in python? suggests adding #!/bin/sh
to the top of the shell script. What’s an analog to that for calling an exe instead of a shell script?
I’m on a Mac, and the file it’s running is https://taxsim.nber.org/stata/taxsim35/taxsim35-unix.exe.
Answers:
subprocess
can only start programs that your operating system knows how to execute.
Your taxsim35-unix.exe
is a Linux executable. MacOS cannot run them.
You’ll need to either use a Linux machine to run this executable (real or virtual), or get a version compiled for Mac. https://back.nber.org/stata//taxsim35/taxsim35-osx.exe is likely to be the latter.
I worked with the developers of taxsim for a while. I believe that the .exe files generated by taxsim were originally msdos only and then moved to Linux. They’re not intended to be run by MacOS. I don’t know if they ever released the FORTRAN code that generates them so that they can be run on MacOS. Your best bet for running taxsim (since there’s no close open-source substitute) is to spin up an AWS or other Linux server.
I’m calling subprocess.Popen
on an exe
file in this script, and it throws:
OSError: [Errno 8] Exec format error: ‘/Users/maxghenis/PolicyEngine/openfisca-us/openfisca_us/tools/dev/taxsim/taxsim35.exe’
The answer to subprocess.Popen(): OSError: [Errno 8] Exec format error in python? suggests adding #!/bin/sh
to the top of the shell script. What’s an analog to that for calling an exe instead of a shell script?
I’m on a Mac, and the file it’s running is https://taxsim.nber.org/stata/taxsim35/taxsim35-unix.exe.
subprocess
can only start programs that your operating system knows how to execute.
Your taxsim35-unix.exe
is a Linux executable. MacOS cannot run them.
You’ll need to either use a Linux machine to run this executable (real or virtual), or get a version compiled for Mac. https://back.nber.org/stata//taxsim35/taxsim35-osx.exe is likely to be the latter.
I worked with the developers of taxsim for a while. I believe that the .exe files generated by taxsim were originally msdos only and then moved to Linux. They’re not intended to be run by MacOS. I don’t know if they ever released the FORTRAN code that generates them so that they can be run on MacOS. Your best bet for running taxsim (since there’s no close open-source substitute) is to spin up an AWS or other Linux server.