# KeyError: ‘chain\_file’

**URL:** <https://openmc.discourse.group/t/keyerror-chain-file/5018>\
**Category:** User Support\
**Created:** [December 2, 2024, 8:27pm UTC](https://openmc.discourse.group/t/keyerror-chain-file/5018 "2024-12-02T20:27:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![birsena](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@birsena](https://openmc.discourse.group/u/birsena)\
**Post date:** [December 2, 2024, 8:27pm UTC](https://openmc.discourse.group/t/keyerror-chain-file/5018/1 "2024-12-02T20:27:33Z")

</div>

\*Hi All,

## _I am trying to use the following lines for my problem. I used “docker run -p 8888:8888 openmc\_with\_jupyter” . I took the lines from an example and created my own folder. When I run I got an error._ _==_================================ **flux\_in\_each\_group, micro\_xs = openmc.deplete.get\_microxs\_and\_flux(** \*\* model=model,\*\* \*\* domains=[shield\_cell],\*\* \*\* energies=[0, 30e6], # one energy bin from 0 to 30MeV\*\* \*\* chain\_file=openmc.config[‘chain\_file’],\*\* **)**

And the error I got is:

* * *

**KeyError Traceback (most recent call last)**  
**Cell In[19], line 5**  
\*\* 1 flux\_in\_each\_group, micro\_xs = openmc.deplete.get\_microxs\_and\_flux(\*\*  
\*\* 2 model=model,\*\*  
\*\* 3 domains=[shield\_cell],\*\*  
\*\* 4 energies=[0, 30e6], # one energy bin from 0 to 30MeV\*\*  
**----\> 5 chain\_file=openmc.config[‘chain\_file’],**  
\*\* 6 )\*\*

**File /openmc\_venv/lib/python3.11/site-packages/openmc/config.py:18, in \_Config.getitem(self, key)**  
\*\* 17 def **getitem** (self, key):\*\*  
**—\> 18 return self.\_mapping[key]**

**KeyError: ‘chain\_file’**

* * *

_Am I supposed to put a file named “chain file” in the same folder? But it seems it is supposed pull out from “chain\_file=openmc.config[‘chain\_file’]”._

_Thank you very much_

_Birsen_

---

<div class="post-metadata">

**Author:** ![magnoxemo](https://avatars.discourse-cdn.com/v4/letter/m/5f8ce5/32.png) [@magnoxemo](https://openmc.discourse.group/u/magnoxemo)\
**Post date:** [December 4, 2024, 12:08am UTC](https://openmc.discourse.group/t/keyerror-chain-file/5018/2 "2024-12-04T00:08:39Z")

</div>

```auto
class _Config(MutableMapping):
    def __init__ (self, data=()):
        self._mapping = {'resolve_paths': True}
        self.update(data)

    def __getitem__ (self, key):
        return self._mapping[key]

```

Maybe your chain\_file (that `key`) variable is wrong. I am guessing that your `OPENMC_CHAIN_FILE` environmental variable is missing. To check that you run `echo $OPENMC_CHAIN_FILE` if it prints out null then you will have to set the `ENV OPENMC_CHAIN_FILE`.

[https://docs.openmc.org/en/stable/usersguide/data.html#usersguide-data-runtime](https://docs.openmc.org/en/stable/usersguide/data.html#usersguide-data-runtime)
