Please print error messages to stderr, like this:

    print('...', file=sys.stderr)