# Buggy code
def do_create_virtualenv(three=None, python=None):
    """Creates a virtualenv."""
    click.echo(crayons.yellow("Creating a virtualenv for this project..."), err=True)

    # The user wants the virtualenv in the project.
    if PIPENV_VENV_IN_PROJECT:
        cmd = [
            "virtualenv",
            project.virtualenv_location,
            "--prompt=({0})".format(project.name),
        ]
    else:
        # Default: use pew.
        cmd = ["pew", "new", project.virtualenv_name, "-d"]

    # Pass a Python version to virtualenv, if needed.
    if python:
        click.echo(
            "{0} {1} {2}".format(
                crayons.yellow("Using"),
                crayons.red(python),
                crayons.yellow("to create virtualenv..."),
            )
        )
    else:
        if os.name == "nt":
            click.echo(
                "{0} If you are running on Windows, you should use the {1} option instead.".format(
                    crayons.red("Warning!"), crayons.green("--python")
                )
            )
        if three is False:
            python = "python2"
        elif three is True:
            python = "python3"
    if python:
        cmd = cmd + ["-p", python]

    # Actually create the virtualenv.
    with spinner():
        c = delegator.run(cmd, block=False)
    click.echo(crayons.blue(c.out), err=True)

    # Say where the virtualenv is.
    do_where(virtualenv=True, bare=False)


# Traceback (pexpect.exceptions.TIMEOUT)
Creating a virtualenv for this project...
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/pexpect/expect.py", line 97, in expect_loop
return self.timeout()
File "/usr/lib/python3.4/site-packages/pexpect/expect.py", line 70, in timeout
raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0x7fe6f4e65f28>
searcher: searcher_re:
0: EOF

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/pipenv", line 9, in <module>
load_entry_point('pipenv==0.2.8', 'console_scripts', 'pipenv')()
File "/usr/lib/python3.4/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3.4/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/lib/python3.4/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3.4/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3.4/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.4/site-packages/pipenv/cli.py", line 393, in install
ensure_project(dev=dev, three=three)
File "/usr/lib/python3.4/site-packages/pipenv/cli.py", line 76, in ensure_project
ensure_virtualenv(three=three)
File "/usr/lib/python3.4/site-packages/pipenv/cli.py", line 57, in ensure_virtualenv
do_create_virtualenv(three=three)
File "/usr/lib/python3.4/site-packages/pipenv/cli.py", line 166, in do_create_virtualenv
click.echo(crayons.blue(c.out))
File "/usr/lib/python3.4/site-packages/delegator.py", line 78, in out
self.__out = self._pexpect_out
File "/usr/lib/python3.4/site-packages/delegator.py", line 66, in _pexpect_out
result += self.subprocess.read().decode('utf-8')
File "/usr/lib/python3.4/site-packages/pexpect/spawnbase.py", line 413, in read
self.expect(self.delimiter)
File "/usr/lib/python3.4/site-packages/pexpect/spawnbase.py", line 321, in expect
timeout, searchwindowsize, async)
File "/usr/lib/python3.4/site-packages/pexpect/spawnbase.py", line 345, in expect_list
return exp.expect_loop(timeout)
File "/usr/lib/python3.4/site-packages/pexpect/expect.py", line 107, in expect_loop
return self.timeout(e)
File "/usr/lib/python3.4/site-packages/pexpect/expect.py", line 70, in timeout
raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0x7fe6f4e65f28>
searcher: searcher_re:
0: EOF
<pexpect.popen_spawn.PopenSpawn object at 0x7fe6f4e65f28>
searcher: searcher_re:
0: EOF

# Fixed code
def do_create_virtualenv(three=None, python=None):
    """Creates a virtualenv."""
    click.echo(crayons.yellow("Creating a virtualenv for this project..."), err=True)

    # The user wants the virtualenv in the project.
    if PIPENV_VENV_IN_PROJECT:
        cmd = [
            "virtualenv",
            project.virtualenv_location,
            "--prompt=({0})".format(project.name),
        ]
    else:
        # Default: use pew.
        cmd = ["pew", "new", project.virtualenv_name, "-d"]

    # Pass a Python version to virtualenv, if needed.
    if python:
        click.echo(
            "{0} {1} {2}".format(
                crayons.yellow("Using"),
                crayons.red(python),
                crayons.yellow("to create virtualenv..."),
            )
        )
    else:
        if os.name == "nt":
            click.echo(
                "{0} If you are running on Windows, you should use the {1} option instead.".format(
                    crayons.red("Warning!"), crayons.green("--python")
                )
            )
        if three is False:
            python = "python2"
        elif three is True:
            python = "python3"
    if python:
        cmd = cmd + ["-p", python]

    # Actually create the virtualenv.
    with spinner():
        c = delegator.run(cmd, block=False, timeout=PIPENV_TIMEOUT)
    click.echo(crayons.blue(c.out), err=True)

    # Say where the virtualenv is.
    do_where(virtualenv=True, bare=False)