code: def in_virtual_env():
      
      import sys
      has_venv = False
      if hasattr(sys, 'real_prefix'):
          # For virtualenv module
          has_venv = True
      elif hasattr(sys, 'base_prefix'):
          # For venv module
          has_venv = sys.base_prefix != sys.prefix
      return has_venv
docs: returns True if you are running inside a python virtual environment.
      (DOES NOT WORK IF IN IPYTHON AND USING A VIRTUALENV)
  
      sys.prefix gives the location of the virtualenv
  
      Notes:
          It seems IPython does not respect virtual environments properly.
          TODO: find a solution
          http://stackoverflow.com/questions/7335992/ipython-and-virtualenv-ignoring-site-packages
  
      References:
          http://stackoverflow.com/questions/1871549/python-determine-if-running-inside-virtualenv
  
      CommandLine:
          python -m utool.util_sysreq in_virtual_env
  
      Example:
          >>> # DISABLE_DOCTEST
          >>> from utool.util_sysreq import *  # NOQA
          >>> import utool as ut
          >>> result = in_virtual_env()
          >>> print(result)