<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _build_env(venv_dir):
 """Create a new virtual environment in `venv_dir`. This uses the base prefix of any virtual environment that you may be using when you call this. """

    # NB: We had to create the because the venv modules wasn't doing what we
    # needed. In particular, if we used it create a venv from an existing venv,
    # it *always* created symlinks back to the original venv's python
    # executables. Then, when you used those linked executables, you ended up
    # interacting with the original venv. I could find no way around this, hence
    # this function.
    prefix = getattr(sys, 'real_prefix', sys.prefix)
    python = Path(prefix) / 'bin' / 'python'
    command = '{} -m venv {}'.format(python, venv_dir)
    try:
        log.info('Creating virtual environment: %s', command)
        subprocess.run(command.split(),
                       stdout=subprocess.PIPE,
                       stderr=subprocess.STDOUT,
                       check=True)
    except subprocess.CalledProcessError as exc:
        log.error("Error creating virtual environment: %s", exc.output)
        raise