<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def change_rc(spark_home, spark_python, py4j):
 """Persists changes to environment by changing shell config. Adds lines to .bashrc to set environment variables including the adding of dependencies to the system path. Will only edit this file if they already exist. Currently only works for bash. Parameters spark_home : str Path to Spark installation. spark_python : str Path to python subdirectory of Spark installation. py4j : str Path to py4j library. """


    bashrc_location = os.path.expanduser("~/.bashrc")

    if os.path.isfile(bashrc_location):
        with open(bashrc_location, 'a') as bashrc:
            bashrc.write("\n# Added by findspark\n")
            bashrc.write("export SPARK_HOME=" + spark_home + "\n")
            bashrc.write("export PYTHONPATH=" + spark_python + ":" +
                         py4j + ":$PYTHONPATH\n\n")