<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def install_extension(conn, extension: str):
 """Install Postgres extension."""


    query = 'CREATE EXTENSION IF NOT EXISTS "%s";'

    with conn.cursor() as cursor:
        cursor.execute(query, (AsIs(extension),))

    installed = check_extension(conn, extension)

    if not installed:
        raise psycopg2.ProgrammingError(
            'Postgres extension failed installation.', extension
        )