Unable to complete "Your first transaction" Python SDK

Here is my error message
It looks as if theres an error in one of the SDK files because its showing errors from lines thats not present in my code

Traceback (most recent call last):
  File "C:\Users\New Age\PycharmProjects\Pure Python\venv\lib\site-packages\algosdk\v2client\algod.py", line 82, in algod_request
    resp = urlopen(req)
  File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Users\New Age\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 649, in http_error_default

Here is my code (my private key is shared, its fine its just for learning purposes)

import json
import base64
from algosdk import account, mnemonic, constants
from algosdk.v2client import algod
from algosdk.future import transaction

def generate_algorand_keypair():
    private_key, address = account.generate_account()
    print("My address: {}".format(address))
    print("My private key: {}".format(private_key))
    print("My passphrase: {}".format(mnemonic.from_private_key(private_key)))

#Write down the address, private key, and the passphrase for later usage

def first_transaction_example(private_key, my_address):
    algod_address = "http://localhost:4001"
    algod_token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    algod_client = algod.AlgodClient(algod_token, algod_address)

    print("My address: {}".format(my_address))
    account_info = algod_client.account_info(my_address)
    print("Account balance: {} microAlgos".format(account_info.get('amount')))

    # build transaction
    params = algod_client.suggested_params()
    # comment out the next two (2) lines to use suggested fees
    params.flat_fee = constants.MIN_TXN_FEE
    params.fee = 1000
    note = "Hello World".encode()

    unsigned_txn = transaction.PaymentTxn(my_address, params, receiver, 1000000, None, note)

    # sign transaction
    signed_txn = unsigned_txn.sign(private_key)

    # submit transaction
    txid = algod_client.send_transaction(signed_txn)
    print("Signed transaction with txID: {}".format(txid))

    # wait for confirmation
        confirmed_txn = transaction.wait_for_confirmation(algod_client, txid, 4)
    except Exception as err:

    print("Transaction information: {}".format(
        json.dumps(confirmed_txn, indent=4)))
    print("Decoded note: {}".format(base64.b64decode(

    print("Starting Account balance: {} microAlgos".format(account_info.get('amount')) )
    print("Amount transfered: {} microAlgos".format(amount) )
    print("Fee: {} microAlgos".format(params.fee) )

    account_info = algod_client.account_info(my_address)
    print("Final Account balance: {} microAlgos".format(account_info.get('amount')) + "\n")

#replace private_key and my_address with your private key and your address
first_transaction_example("Kp91CqffmHaYXjTUHreHeugg6np1e61HMIxr2p3MZAuQ8PkgIG461Mif0uES4TQJXed5n6Xp3uCIxNlKQCghDQ==", "SDYPSIBANY5NJSE72LQRFYJUBFO6O6M7UXU55YEIYTMUUQBIEEGRITJWWU")

what is the error?

It looks as if theres an error in one of the SDK files because its showing errors from lines thats not present in my code

I’ve re-edited your post to write code in triple backquotes so that it’s easier to read.

Most likely the issue is that the sandbox is not running properly.
See all the discussion on Error in Example - Build with Python - #3 by fabrice

(Your error message is not complete, so we cannot be completely certain it’s the issue.)

Agree w Fabrice. I could not recreate the problem. The only url that is opened is on this line:

algod_client = algod.AlgodClient(algod_token, algod_address)

Is the sand box up? if so, you may want to do a ./sandbox clean and ./sandbox up (testnet) if using testnet.
What line in your code is blowing up?

Or you can try another node… ? This is one we use for our demos:
algod_address = “http://hackathon.algodev.network:9100
algod_token = “ef920e2e7e002953f4b29a8af720efe8e4ecc75ff102b165e0472834b25832c1”

One other thing is to make sure you have the latest python SDK which looks like you do by using the waitforconfirmation SDK method (new to SDK)

pip3 uninstall py-algorand-sdk
pip3 install py-algorand-sdk

verify installed version

pip3 list | grep “py-algorand-sdk”

What version are you getting?
This is the latest: v1.10.0b1 … check at: Releases · algorand/py-algorand-sdk · GitHub

So here I’m running into an invalid syntax error after copying and pasting the the node you use for demos – theres probably other errors but if you can spot em let me know what to fix to get this transaction to clear

Here is an update, that I am trying to troubleshoot and see my error

This error is because the quotes are the wrong ones.
Be sure to use the character " and no variation of it.
Some Word processors / websites modify the quotes with smart quotes that won’t work for code.

Here is the issue is that you’re missing some Python imports. See a full example will all the imports there:

so it looks like the transaction went through but I encountered this error. – I’m pulling all the lines of code from the full code base, and the node i pulled from a previous answer here (since that was my original issue) but here is my current error

The issue is just that you must have removed the variable amount and directly wrote it or something like that.
In any case, if you arrived there, everything is working, it’s just a small issue in your code.

what is the proper line of code to fix this small error?