# Buggy code
def create_pipfile(self, python=None):
    """Creates the Pipfile, filled with juicy defaults."""
    config_parser = ConfigOptionParser(name=self.name)
    install = dict(config_parser.get_config_section("install"))
    indexes = install.get("extra-index-url", "").lstrip("\n").split("\n")

    if PIPENV_TEST_INDEX:
        sources = [{"url": PIPENV_TEST_INDEX, "verify_ssl": True, "name": "custom"}]
    else:
        # Default source.
        pypi_source = {
            "url": "https://pypi.python.org/simple",
            "verify_ssl": True,
            "name": "pypi",
        }
        sources = [pypi_source]

        for i, index in enumerate(indexes):
            if not index:
                continue
            source_name = "pip_index_{}".format(i)
            verify_ssl = index.startswith("https")

            sources.append(
                {"url": index, "verify_ssl": verify_ssl, "name": source_name}
            )

    data = {
        "source": sources,
        # Default packages.
        "packages": {},
        "dev-packages": {},
    }

    # Default requires.
    required_python = (
        python if python else self.which("python", self.virtualenv_location)
    )
    data["requires"] = {"python_version": python_version(required_python)[: len("2.7")]}

    self.write_toml(data, "Pipfile")


# Traceback (TypeError)
saviles  ~  1  docker run --rm -ti fedora:27 /bin/bash
[root@0958ee759ab3 /]# dnf install -qy which
install-info: No such file or directory for /usr/share/info/which.info.gz
[root@0958ee759ab3 /]# pip3 install --user pipenv
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pipenv
Downloading pipenv-11.2.0.tar.gz (4.1MB)
100% |████████████████████████████████| 4.1MB 412kB/s
Collecting setuptools>=36.2.1 (from pipenv)
Downloading setuptools-38.5.2-py2.py3-none-any.whl (490kB)
100% |████████████████████████████████| 491kB 2.3MB/s
Collecting virtualenv (from pipenv)
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 810kB/s
Collecting virtualenv-clone>=0.2.5 (from pipenv)
Downloading virtualenv_clone-0.3.0-py2.py3-none-any.whl
Installing collected packages: setuptools, virtualenv, virtualenv-clone, pipenv
Running setup.py install for pipenv ... done
Successfully installed pipenv-11.2.0 setuptools-38.5.2 virtualenv-15.1.0 virtualenv-clone-0.3.0
[root@0958ee759ab3 /]# mkdir /tmp/test1
[root@0958ee759ab3 /]# cd /tmp/test1
[root@0958ee759ab3 test1]# python3 -m pipenv install requests
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this project…
⠋Using base prefix '/usr'
New python executable in /root/.local/share/virtualenvs/test1-MiVIN7Yf/bin/python3
Also creating executable in /root/.local/share/virtualenvs/test1-MiVIN7Yf/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location:
Creating a Pipfile for this project…
Traceback (most recent call last):
File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/root/.local/lib/python3.6/site-packages/pipenv/__main__.py", line 4, in <module>
cli()
File "/root/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/root/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/root/.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 "/root/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/root/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/root/.local/lib/python3.6/site-packages/pipenv/cli.py", line 197, in install
selective_upgrade=selective_upgrade
File "/root/.local/lib/python3.6/site-packages/pipenv/core.py", line 1767, in do_install
ensure_project(three=three, python=python, system=system, warn=True, deploy=deploy, skip_requirements=skip_requirements)
File "/root/.local/lib/python3.6/site-packages/pipenv/core.py", line 688, in ensure_project
ensure_pipfile(validate=validate, skip_requirements=skip_requirements)
File "/root/.local/lib/python3.6/site-packages/pipenv/core.py", line 341, in ensure_pipfile
project.create_pipfile(python=python)
File "/root/.local/lib/python3.6/site-packages/pipenv/project.py", line 439, in create_pipfile
data[u'requires'] = {'python_version': python_version(self.which('python'))[:len('2.7')]}
TypeError: 'NoneType' object is not subscriptable

# Fixed code
def create_pipfile(self, python=None):
    """Creates the Pipfile, filled with juicy defaults."""
    config_parser = ConfigOptionParser(name=self.name)
    install = dict(config_parser.get_config_section("install"))
    indexes = install.get("extra-index-url", "").lstrip("\n").split("\n")

    if PIPENV_TEST_INDEX:
        sources = [{"url": PIPENV_TEST_INDEX, "verify_ssl": True, "name": "custom"}]
    else:
        # Default source.
        pypi_source = {
            "url": "https://pypi.python.org/simple",
            "verify_ssl": True,
            "name": "pypi",
        }
        sources = [pypi_source]

        for i, index in enumerate(indexes):
            if not index:
                continue
            source_name = "pip_index_{}".format(i)
            verify_ssl = index.startswith("https")

            sources.append(
                {"url": index, "verify_ssl": verify_ssl, "name": source_name}
            )

    data = {
        "source": sources,
        # Default packages.
        "packages": {},
        "dev-packages": {},
    }

    # Default requires.
    required_python = python or self.which("python", self.virtualenv_location)
    data["requires"] = {"python_version": python_version(required_python)[: len("2.7")]}

    self.write_toml(data, "Pipfile")