<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_API_key(api_key, profile_name='default'):
 """Put the given API key into the given profile name."""

    fname = API_profile_fname(profile_name)
    if not os.path.isdir(os.path.dirname(fname)):
        os.makedirs(os.path.dirname(fname))
    with open(fname, 'w') as fh:
        fh.write(api_key)