https://github.com/inoutcode/bitcoin_book_2nd/blob/b9514815787237ab0a5115b8d811e6e406fa2065/code/key-to-address-ecc-example.py#L24 there should be private_key not compressed_private_key or,u can see wif_compressed_private_key not startwith "K"