What web3.py version do you use?
It seems you use web3 >= v6.0.0 where deprecated camelCase methods were removed in favor of snake_case ones while your code has been written for <v6.0.0.
In this case, you should replace:
buildTransaction with build_transactiongetTransactionCount with get_transaction_countDo not change swapExactETHForTokens though, as it's part of the ABI.