# Buggy code
def actually_resolve_reps(
    deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre
):
    class PipCommand(pip.basecommand.Command):
        """Needed for pip-tools."""

        name = "PipCommand"

    constraints = []

    for dep in deps:
        t = tempfile.mkstemp(prefix="pipenv-", suffix="-requirement.txt")[1]
        with open(t, "w") as f:
            f.write(dep)

        if dep.startswith("-e "):
            constraint = pip.req.InstallRequirement.from_editable(dep[len("-e ") :])
        else:
            constraint = [
                c for c in pip.req.parse_requirements(t, session=pip._vendor.requests)
            ][0]
            # extra_constraints = []

        if " -i " in dep:
            index_lookup[constraint.name] = project.get_source(
                url=dep.split(" -i ")[1]
            ).get("name")

        if constraint.markers:
            markers_lookup[constraint.name] = str(constraint.markers).replace('"', "'")

        constraints.append(constraint)

    pip_command = get_pip_command()

    pip_args = []

    if sources:
        pip_args = prepare_pip_source_args(sources, pip_args)

    if verbose:
        print("Using pip: {0}".format(" ".join(pip_args)))

    pip_options, _ = pip_command.parse_args(pip_args)

    session = pip_command._build_session(pip_options)
    pypi = PyPIRepository(pip_options=pip_options, session=session)

    if verbose:
        logging.log.verbose = True

    resolved_tree = set()

    resolver = Resolver(
        constraints=constraints, repository=pypi, clear_caches=clear, prereleases=pre
    )
    # pre-resolve instead of iterating to avoid asking pypi for hashes of editable packages
    try:
        resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
    except (NoCandidateFound, DistributionNotFound, HTTPError) as e:
        click.echo(
            "{0}: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.\n  "
            "You can use {1} to bypass this mechanism, then run {2} to inspect the situation."
            "".format(
                crayons.red("Warning", bold=True),
                crayons.red("$ pipenv install --skip-lock"),
                crayons.red("$ pipenv graph"),
            ),
            err=True,
        )

        click.echo(crayons.blue(e))

        if "no version found at all" in str(e):
            click.echo(
                crayons.blue(
                    "Please check your version specifier and version number. See PEP440 for more information."
                )
            )

        raise RuntimeError

    return resolved_tree, resolver


# Traceback (FileNotFoundError)
Traceback (most recent call last):
File "/home/daniel/.local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/cli.py", line 1865, in install
do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy, pre=pre)
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/cli.py", line 1311, in do_init
do_lock(system=system, pre=pre)
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/cli.py", line 1102, in do_lock
pre=pre
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/utils.py", line 557, in resolve_deps
resolved_tree = actually_resolve_reps(deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre)
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/utils.py", line 507, in actually_resolve_reps
resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
has_changed, best_matches = self._resolve_one_round()
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 200, in _resolve_one_round
for dep in self._iter_dependencies(best_match):
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 274, in _iter_dependencies
for dependency in self.repository.get_dependencies(ireq):
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 153, in get_dependencies
result = reqset._prepare_file(self.finder, ireq)
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 523, in _prepare_file
abstract_dist.prep_for_dist()
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 134, in prep_for_dist
self.req_to_install.run_egg_info()
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_install.py", line 438, in run_egg_info
command_desc='python setup.py egg_info')
File "/home/daniel/.local/lib/python3.6/site-packages/pipenv/patched/pip/utils/__init__.py", line 667, in call_subprocess
cwd=cwd, env=env)
File "/usr/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '"/usr/bin/python3"': '"/usr/bin/python3"'

# Fixed code
def actually_resolve_reps(
    deps, index_lookup, markers_lookup, project, sources, verbose, clear, pre
):
    class PipCommand(pip.basecommand.Command):
        """Needed for pip-tools."""

        name = "PipCommand"

    constraints = []

    for dep in deps:
        t = tempfile.mkstemp(prefix="pipenv-", suffix="-requirement.txt")[1]
        with open(t, "w") as f:
            f.write(dep)

        if dep.startswith("-e "):
            constraint = pip.req.InstallRequirement.from_editable(dep[len("-e ") :])
        else:
            constraint = [
                c for c in pip.req.parse_requirements(t, session=pip._vendor.requests)
            ][0]
            # extra_constraints = []

        if " -i " in dep:
            index_lookup[constraint.name] = project.get_source(
                url=dep.split(" -i ")[1]
            ).get("name")

        if constraint.markers:
            markers_lookup[constraint.name] = str(constraint.markers).replace('"', "'")

        constraints.append(constraint)

    pip_command = get_pip_command()

    pip_args = []

    if sources:
        pip_args = prepare_pip_source_args(sources, pip_args)

    if verbose:
        print("Using pip: {0}".format(" ".join(pip_args)))

    pip_options, _ = pip_command.parse_args(pip_args)

    session = pip_command._build_session(pip_options)
    pypi = PyPIRepository(pip_options=pip_options, session=session)

    if verbose:
        logging.log.verbose = True

    resolved_tree = set()

    resolver = Resolver(
        constraints=constraints, repository=pypi, clear_caches=clear, prereleases=pre
    )
    # pre-resolve instead of iterating to avoid asking pypi for hashes of editable packages
    try:
        resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
    except (NoCandidateFound, DistributionNotFound, HTTPError) as e:
        click.echo(
            "{0}: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.\n  "
            "You can use {1} to bypass this mechanism, then run {2} to inspect the situation."
            "".format(
                crayons.red("Warning", bold=True),
                crayons.red("$ pipenv install --skip-lock"),
                crayons.red("$ pipenv graph"),
            ),
            err=True,
        )

        click.echo(crayons.blue(str(e)))

        if "no version found at all" in str(e):
            click.echo(
                crayons.blue(
                    "Please check your version specifier and version number. See PEP440 for more information."
                )
            )

        raise RuntimeError

    return resolved_tree, resolver