<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_egg(self, egg_name):
 """ Install an egg into the egg directory """

        if not os.path.exists(self.egg_directory):
            os.makedirs(self.egg_directory)
        self.requirement_set.add_requirement(
            InstallRequirement.from_line(egg_name, None))
        try:
            self.requirement_set.prepare_files(self.finder)
            self.requirement_set.install(['--prefix=' + self.egg_directory], [])
        except DistributionNotFound:
            self.requirement_set.requirements._keys.remove(egg_name)
            raise PipException()