I can't reproduce this exact problem on my own computer, so I can't give specific advice, but here is some general commentary on how to debug this sort of thing.
When you see "Invalid argument" in an IOError or OSError exception from python, that means the interpreter tried to make a system call, which failed and set errno
to the code EINVAL
. (Tangentially, python really shouldn't print the numeric values for errno codes - the symbolic names are standardized but the numbers aren't.) The first thing you need to do is find out which system call it was, and the easiest way to do that is run your program under the strace
utility, like this:
$ strace -f -o strace.log python yourscript.py [arguments...]
Wait for it to fail, then search the file strace.log
for "-1 E" (exactly that string). You will find something like this:
times({tms_utime=162, tms_stime=123, tms_cutime=0, tms_cstime=0}) = 1718279979
write(1, "2.85\n", 5) = -1 EINVAL (Invalid argument)
You then read the man page for the system call that failed ("man 2 write
" in this case) and look for the errno code name (EINVAL
in this case), and see what it says has gone wrong.
In this case I strongly suspect you have found a bug in either the Python interpreter or the operating system. "Invalid argument" means what it says - one of the input arguments to the system call had an invalid value. You're not doing anything tricky in your script, so either the interpreter is messing up its system calls, or the kernel misunderstood what the interpreter wanted.