title: How to use python-dotenv's "find_dotenv" method
body: <p>I've pip-installed the <a href="https://pypi.python.org/pypi/python-dotenv" rel="nofollow noreferrer">python-dotenv</a> module and am trying to use it as follows. I've created a directory <code>test_dotenv</code> with the following tree:</p>
  
  <pre><code>.
  ├── config.env
  └── test_dotenv_subdir
      └── test_dotenv.py
  </code></pre>
  
  <p>The <code>config.env</code> file is simply an empty file, while <code>test_dotenv.py</code> contains the following:</p>
  
  <pre><code>import dotenv
  
  found_dotenv = dotenv.find_dotenv()
  print(found_dotenv)
  </code></pre>
  
  <p>However, if I run this script using <code>python test_dotenv.py</code>, I find that nothing gets printed; that is, <code>found_dotenv</code> is an empty string (<code>''</code>).</p>
  
  <p>Am I missing something about how to use this method? As far as I can tell, here is the relevant part of the <a href="https://github.com/theskumar/python-dotenv/tree/master/dotenv" rel="nofollow noreferrer">source code</a>:</p>
  
  <pre><code>def _walk_to_root(path):
      """
      Yield directories starting from the given directory up to the root
      """
      if not os.path.exists(path):
          raise IOError('Starting path not found')
  
      if os.path.isfile(path):
          path = os.path.dirname(path)
  
      last_dir = None
      current_dir = os.path.abspath(path)
      while last_dir != current_dir:
          yield current_dir
          parent_dir = os.path.abspath(os.path.join(current_dir, os.path.pardir))
          last_dir, current_dir = current_dir, parent_dir
  
  
  def find_dotenv(filename='.env', raise_error_if_not_found=False, usecwd=False):
      """
      Search in increasingly higher folders for the given file
  
      Returns path to the file if found, or an empty string otherwise
      """
      if usecwd or '__file__' not in globals():
          # should work without __file__, e.g. in REPL or IPython notebook
          path = os.getcwd()
      else:
          # will work for .py files
          frame_filename = sys._getframe().f_back.f_code.co_filename
          path = os.path.dirname(os.path.abspath(frame_filename))
  
      for dirname in _walk_to_root(path):
          check_path = os.path.join(dirname, filename)
          if os.path.exists(check_path):
              return check_path
  
      if raise_error_if_not_found:
          raise IOError('File not found')
  
      return ''
  </code></pre>
  
  <p>It seems like <code>os.path.exists(check_path)</code> keeps on returning <code>False</code>, so that the in the end an empty string is returned. Why is this not working as intended?</p>