The script currently fails with
Traceback (most recent call last):
File "./gen_key_io_test_vectors.py", line 18, in <module>
from segwit_addr import bech32_encode, decode, convertbits, CHARSET
ImportError: cannot import name 'decode' from 'segwit_addr'
Fix that.
Also, unrelated cleanup to use the bytearray.hex() method instead of importing a library. https://docs.python.org/3.5/library/stdtypes.html#bytes.hex