Check for python error when needs_api flag is set