# Buggy code
def build_venv(cls, path, executable=None):
    if executable is not None:
        # Create virtualenv by using an external executable
        try:
            p = subprocess.Popen(
                list_to_shell_command([executable, "-"]),
                stdin=subprocess.PIPE,
                shell=True,
            )
            p.communicate(encode(CREATE_VENV_COMMAND.format(path)))
        except CalledProcessError as e:
            raise EnvCommandError(e)

        return

    try:
        from venv import EnvBuilder

        # use the same defaults as python -m venv
        if os.name == "nt":
            use_symlinks = False
        else:
            use_symlinks = True

        builder = EnvBuilder(with_pip=True, symlinks=use_symlinks)
        build = builder.create
    except ImportError:
        # We fallback on virtualenv for Python 2.7
        from virtualenv import create_environment

        build = create_environment

    build(path)


# Traceback (ImportError)
circleci@32ce45b8e19b:~/project$ poetry install -v
Creating virtualenv carly-3aSsmiER-py2.7 in /home/circleci/.cache/pypoetry/virtualenvs

[ImportError]
cannot import name create_environment

Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/clikit/console_application.py", line 131, in run
status_code = command.handle(parsed_args, io)
File "/usr/local/lib/python2.7/site-packages/clikit/api/command/command.py", line 120, in handle
status_code = self._do_handle(args, io)
File "/usr/local/lib/python2.7/site-packages/clikit/api/command/command.py", line 163, in _do_handle
self._dispatcher.dispatch(PRE_HANDLE, event)
File "/usr/local/lib/python2.7/site-packages/clikit/api/event/event_dispatcher.py", line 22, in dispatch
self._do_dispatch(listeners, event_name, event)
File "/usr/local/lib/python2.7/site-packages/clikit/api/event/event_dispatcher.py", line 89, in _do_dispatch
listener(event, event_name, self)
File "/usr/local/lib/python2.7/site-packages/poetry/console/config/application_config.py", line 89, in set_env
env = env_manager.create_venv(io)
File "/usr/local/lib/python2.7/site-packages/poetry/utils/env.py", line 610, in create_venv
self.build_venv(str(venv), executable=executable)
File "/usr/local/lib/python2.7/site-packages/poetry/utils/env.py", line 674, in build_venv
from virtualenv import create_environment

# Fixed code
def build_venv(cls, path, executable=None):
    if executable is not None:
        # Create virtualenv by using an external executable
        try:
            p = subprocess.Popen(
                list_to_shell_command([executable, "-"]),
                stdin=subprocess.PIPE,
                shell=True,
            )
            p.communicate(encode(CREATE_VENV_COMMAND.format(path)))
        except CalledProcessError as e:
            raise EnvCommandError(e)

        return

    try:
        from venv import EnvBuilder

        # use the same defaults as python -m venv
        if os.name == "nt":
            use_symlinks = False
        else:
            use_symlinks = True

        builder = EnvBuilder(with_pip=True, symlinks=use_symlinks)
        builder.create(path)
    except ImportError:
        try:
            # We fallback on virtualenv for Python 2.7
            from virtualenv import create_environment

            create_environment(path)
        except ImportError:
            # since virtualenv>20 we have to use cli_run
            from virtualenv import cli_run

            cli_run([path])