Capture failed: a bytes-like object is required, not 'str'