In Pset8, I continue to get the "API_KEY" not set runtime error, even though i crosschecked with:

echo $API_KEY

and the response was:


which matched the key that i exported. Read the answer below to understand how to fix this ANNOYING bug.


This can be easily solved by noting which terminal the export command was executed in the same terminal window that flask is running in (will be prompted to run in after the export command). Otherwise, flask cannot recognize the API_KEY as an environment variable, hardly being an environment variable.

  • 1
    Thanks Karthik :) Aug 31 '17 at 16:29
  • np ;) i suffered too long for this on pset 8 Oct 26 '17 at 4:47
  • 1
    thanks Karthik. You suffered so we didn't have to. Oct 26 '17 at 9:15
  • how should i export the api_key if I am doing the same pset on vscode?
    – Praful
    Jun 21 '19 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .