KeyError: 'PROD' when starting

System specs: Windows 10, Anaconda, Python 3.8.5

I have referred to the following tickets:

These are the contents of my dotini_win file which I renamed to .ini:



MFLIX_DB_URI = mongodb+srv://

MFLIX_NS = sample_mflix



MFLIX_DB_URI = mongodb+srv://

MFLIX_NS = sample_mflix

After having set up my virtual environment and finished installing the requirements, I ran the command python but get the following error:

Traceback (most recent call last):

File "", line 13, in <module>

app.config['MFLIX_DB_URI'] = config['PROD']['MFLIX_DB_URI']

File "C:\Users\Username\anaconda3\lib\", line 960, in __getitem__

raise KeyError(key)

KeyError: 'PROD'

Please advise as I can’t seem to get past this.

Post a screenshot of the terminal where you ran the command that shows the error you are having.

The context often provides more clues than just the error message.


It looks like you have not create or activate your mflix virtual environment. Make sure you install the requirements once it is done.

No @steevej. I had already created and activated it.

Please share the output of executing dir command from the same directory.

I am surprise that after you run the command activate mflix, your prompt still show (base) PS …*. It is supposed to show (mflix) PS ….

But I know not much about python, actually I do not like python at all, they made the same mistake make authors made 30 years later, they should have know better not to make an invisible character important to the syntax.

hey there, I have tested what could be the problem, and it is clearly a step you missed or took a wrong turn there. you get this error because app can’t find .ini (with a leading dot)

Ygo to your m220p folder and copy “dotini_win” to “.ini” :
copy dotini_win .ini

then edit that file with notepad or whatever editor you use.
notepad .ini

1 Like

@Yilmaz_Durmaz I have already done this prior to running my code. I followed the instructions step by step yet I am facing this issue.

it is clear that configparser package is installed, and is run in the the problem with it is that it wont show an error if the given config file does not exist.

you can inspect the problem by opening a REPL in that folder (simply go into that folder, open console, “activate” environment, and just type python, in case you forgot).

then copy-paste these lines into it (they are part of

import os
import configparser
config = configparser.ConfigParser()".ini")))

if .ini file is not there, then it will print an empty array, [], indicating you messed with the name of the file, or copied it into the wrong folder.

if it is there, you will see ['c:\\Users\\Ganesh\\mflix-python\\.ini'] .
in this case, use this next line to confirm you have PROD in your file:


then what you should get is "‘mongodb+srv://…’

and if you get the error in this last step (the same error you get), that would mean you messed inside the ini file. then you need to repeat the copy-edit process for the ini file.


I met the same issue. I fixed this by change “dotini_unix” to “.ini” not “dotini_unix.ini”

Hope it will be helpful for those meet the same problem.