Where you see everything printed twice. I notice that in addition, you have
> r/folders/kz/1c2cxn1x60n_t5p2j1p02b180000gn/T/py6499_X0''', 'exec'));
at the top of your buffer, and I do not. I think the "exec" might be causing everything to echo as it runs, so everything is printed 2x, and that confuses Org, and it is not able to capture your filename.