title: Can't read from .ini file using configparser
body: <p>I recently started learning python and I'm getting this issue where, using configparser to read a key from an ini file, it keep raising a key error.</p>
  <p>I have two files:</p>
  <p>weather.py</p>
  <pre class="lang-py prettyprint-override"><code>import configparser
  
  def get_api_key():
      config = configparser.ConfigParser()
      config.read('config.ini')
      return config['openweathermap']['api_key']
  
  print(get_api_key())
  </code></pre>
  <p>and config.ini</p>
  <pre><code>[openweathermap]
  api_key=e53647dc71abcf81c779b83f1a8807c1
  </code></pre>
  <p>both files are placed in the same folder.</p>
  <p>using <code>print(get_api_key())</code> gives me this error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;...\weather.py&quot;, line 8, in &lt;module&gt;
      print(get_api_key())
    File &quot;...\weather.py&quot;, line 6, in get_api_key
      return config['openweathermap']['api_key']
    File &quot;C:\Users\username\AppData\Local\Programs\Python\Python310\lib\configparser.py&quot;, line 964, in __getitem__
      raise KeyError(key)
  KeyError: 'openweathermap'
  </code></pre>
  <p>Would it be possible to get some help?
  Thanks in advance.</p>
  <p><strong>Edit</strong>:
  &quot;balderman&quot; asked me to show that both files are in the same directory,so I <code>cd</code>'d into the folder and used <code>ls</code>:</p>
  <pre><code>Mode                 LastWriteTime         Length Name
  ----                 -------------         ------ ----
  d-----         13-Nov-21     22:31                __pycache__
  -a----         13-Nov-21     23:03              0 config.ini
  -a----         13-Nov-21     23:03            737 weather.py
  </code></pre>