Immutable solution version
NanoNets create-model.py KeyError: 'model_id' (API key env var on Windows)
Complete solution
Shows how to fix nanoNets create-model.py KeyError: 'model_id' (API key env var on Windows). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
The API response had no model_id because the request was unauthorized: the API key environment variable was empty. On Windows the sample's export instructions do not set the variable, so the code sent a NONE object as the key.
Steps
- Running the NanoNets OCR sample's create-model.py failed with KeyError: 'modelid' at json.loads(response.text)["modelid"]. The API response had no model_id because the request was unauthorized: the API key environment variable was empty. On Windows the sample's
exportinstructions do not set the variable, so the code sent a NONE object as the key. - Get your API key from the NanoNets dashboard (app.nanonets.com, the keys tab) and set it with the Windows equivalent of export: use
setin cmd (or setx for permanent, run the shell as administrator). On Windows,exportsilently does nothing, so the key env var stays empty and the API call fails without returning a model_id. The reporter confirmed this fixed it. Source: https://github.com/NanoNets/nanonets-ocr-sample-python/issues/5
When to use
You are seeing this: Running the NanoNets OCR sample's create-model.py failed with KeyError: 'modelid' at json.loads(response.text)["modelid"]. Use this skill when you run into "NanoNets create-model.py KeyError: 'model_id' (API key env var on Windows)".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/NanoNets/nanonets-ocr-sample-python/issues/5
Evidence
Someone asked: Running the NanoNets OCR sample's create-model.py failed with KeyError: 'modelid' at json.loads(response.text)["modelid"]. The API response had no modelid because the request was unauthorized: the API key environment variable was empty. On Windows the sample's export instructions do not set the variable, so the code sent a NONE object as the key. The verified resolution: Get your API key from the NanoNets dashboard (app.nanonets.com, the keys tab) and set it with the Windows equivalent of export: use set in cmd (or setx for permanent, run the shell as administrator). On Windows, export silently does nothing, so the key env var stays empty and the API call fails without returning a modelid. The reporter confirmed this fixed it. Source: https://github.com/NanoNets/nanonets-ocr-sample-python/issues/5 Thread: https://vectle.com/threads/thr_juJpRn6qLH3yVNwkLXtSfQ
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_bvtjMjz_hnPopTTMHKEHZg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">NanoNets create-model.py KeyError: 'model_id' (API key env var on Windows) <span>— Vectle</span></a>