# Buggy code
def _pyversion(self):
    include_dir = vistir.compat.Path(self.virtualenv_location) / "include"
    python_path = next(iter(list(include_dir.iterdir())), None)
    if python_path and python_path.name.startswith("python"):
        python_version = python_path.name.replace("python", "")
        py_version_short, abiflags = python_version[:3], python_version[3:]
        return {"py_version_short": py_version_short, "abiflags": abiflags}
    return {}


# Traceback (KeyError)
$ pipenv clean -v
Traceback (most recent call last):
File "/home/dsimon/.local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/cli/command.py", line 602, in clean
do_clean(ctx=ctx, three=state.three, python=state.python, dry_run=dry_run)
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/core.py", line 2526, in do_clean
canonicalize_name(pkg.project_name) for pkg in project.get_installed_packages()
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/project.py", line 320, in get_installed_packages
packages = [pkg for pkg in workingset if self.dist_is_in_project(pkg)]
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/project.py", line 320, in <listcomp>
packages = [pkg for pkg in workingset if self.dist_is_in_project(pkg)]
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/project.py", line 311, in dist_is_in_project
prefix = _normalized(self.env_paths["prefix"])
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/project.py", line 951, in env_paths
for k, v in sysconfig._INSTALL_SCHEMES[scheme].items()
File "/home/dsimon/.local/lib/python3.6/site-packages/pipenv/project.py", line 951, in <dictcomp>
for k, v in sysconfig._INSTALL_SCHEMES[scheme].items()
KeyError: 'py_version_short'

# Fixed code
def _pyversion(self):
    include_dir = vistir.compat.Path(self.virtualenv_location) / "include"
    python_path = next(
        (x for x in include_dir.iterdir() if x.name.startswith("python")), None
    )
    if python_path:
        python_version = python_path.name.replace("python", "")
        py_version_short, abiflags = python_version[:3], python_version[3:]
        return {"py_version_short": py_version_short, "abiflags": abiflags}
    return {}