<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pip_upgrade_all(line):
 """Attempt to upgrade all packages"""

    from pip import get_installed_distributions
    user = set(d.project_name for d in get_installed_distributions(user_only=True))
    all = set(d.project_name for d in get_installed_distributions())
    for dist in all - user:
        do_pip(["install", "--upgrade", dist])
    for dist in  user:
        do_pip(["install", "--upgrade", "--user", dist])