<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add(self, addon, dev=False, interactive=True):
 """Add a new dependency and install it."""

        dependencies = self.get_dependency_manager(dev=dev)
        other_dependencies = self.get_dependency_manager(dev=not dev)
        existing = dependencies.get(addon)
        self.stdout.write(style.format_command('Adding', addon))
        dependencies.add(addon)
        try:
            # try running the build
            self.build()
            self.refresh()

            # remove version of this in other requirements file
            other_dependencies.remove(addon, warn=False)

            # run new addon constructor
            constructor_name = '%s.init' % Dependency(addon).module_name
            constructor = self.blueprints.get(constructor_name)

            if constructor:
                context = constructor.load_context().main(
                    [], standalone_mode=False
                )
                self.generate(constructor, context, interactive=interactive)
        except Exception as e:
            # restore original settings
            self.stdout.write(style.red(str(e)))
            self.stdout.write(
                style.yellow('Could not find %s' % addon)
            )
            dependencies.remove(addon)
            if existing:
                dependencies.add(existing)
            return