def is_in_virtualenv():
    """
    :return: True if we are currently in a virtualenv, else False
    :rtype: ``Boolean``
    """
    # sys.real_prefix is for virtualenv
    # sys.base_prefix != sys.prefix is for venv
    return hasattr(sys, "real_prefix") or (
        hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix
    )

    :return: True if we are currently in a virtualenv, else False
    :rtype: ``Boolean``
    
st2common/st2common/util/sandboxing.py