Try to convert string to the bytes with the encode() method in Python 3.5:
import hashlib import hmac key = 'c41d9eac' print(hmac.new(key.encode(), 'this is the life'.encode(), hashlib.sha1).hexdigest())