def create(name_or_path=None, config=None):
<EOL>if utils.is_system_path(name_or_path):<EOL><INDENT>path = unipath(name_or_path)<EOL><DEDENT>else:<EOL><INDENT>path = unipath(get_home_path(), name_or_path)<EOL><DEDENT>if os.path.exists(path):<EOL><INDENT>raise OSError('<STR_LIT>'.format(path))<EOL><DEDENT>env = VirtualEnvironment(path)<EOL>utils.ensure_path_exists(env.path)<EOL>if config:<EOL><INDENT>if utils.is_git_repo(config):<EOL><INDENT>Git('<STR_LIT>').clone(config, env.path)<EOL><DEDENT>else:<EOL><INDENT>shutil.copy2(config, env.config_path)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with open(env.config_path, '<STR_LIT:w>') as f:<EOL><INDENT>f.write(defaults.environment_config)<EOL><DEDENT><DEDENT>utils.ensure_path_exists(env.hook_path)<EOL>utils.ensure_path_exists(env.modules_path)<EOL>env.run_hook('<STR_LIT>')<EOL>virtualenv.create_environment(env.path)<EOL>if not utils.is_home_environment(env.path):<EOL><INDENT>EnvironmentCache.add(env)<EOL>EnvironmentCache.save()<EOL><DEDENT>try:<EOL><INDENT>env.update()<EOL><DEDENT>except:<EOL><INDENT>utils.rmtree(path)<EOL>logger.debug('<STR_LIT>')<EOL>raise<EOL><DEDENT>else:<EOL><INDENT>env.run_hook('<STR_LIT>')<EOL><DEDENT>return env<EOL>
Create a virtual environment. You can pass either the name of a new
    environment to create in your CPENV_HOME directory OR specify a full path
    to create an environment outisde your CPENV_HOME.

    Create an environment in CPENV_HOME::

        >>> cpenv.create('myenv')

    Create an environment elsewhere::

        >>> cpenv.create('~/custom_location/myenv')

    :param name_or_path: Name or full path of environment
    :param config: Environment configuration including dependencies etc...