What Can Lead To “IOError: [Errno 9] Bad File Descriptor” During Os.System()?

597    Asked by Amitjaisawal in Tableau , Asked on Nov 18, 2022

 I'm using os.system(), which is a scientific software including a python script, used to run another scientific program. There's a subprocess, which will be running and python will print the following:

close failed in file object destructor:
IOError: [Errno 9] Bad file descriptor

Even this message will be printed at the same time as os.system()?

But my question is, Which condition will lead to this type of IOError? What is it?

Answered by ananya Pawar
You can get this oserror errno 9 bad file descriptor if you use wrong mode when opening the file. For example:

    with open(output, 'wb') as output_file:
        print output_file.read()
In that code, I want to read the file, but I use mode wb instead of r or r+


Your Answer

Interviews

Parent Categories