# Error in MedCATtrainer Project Setup: Missing "spacy\_model"

**URL:** <https://discourse.cogstack.org/t/error-in-medcattrainer-project-setup-missing-spacy-model/246>\
**Category:** MedCAT\
**Created:** [November 16, 2023, 9:29am UTC](https://discourse.cogstack.org/t/error-in-medcattrainer-project-setup-missing-spacy-model/246 "2023-11-16T09:29:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tapak](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@tapak](https://discourse.cogstack.org/u/tapak)\
**Post date:** [November 16, 2023, 9:29am UTC](https://discourse.cogstack.org/t/error-in-medcattrainer-project-setup-missing-spacy-model/246/1 "2023-11-16T09:29:37Z")

</div>

Hello,

We’re currently in the process of setting up a project in MedCATtrainer. We’ve uploaded the `vocab.dat` and `cdb.dat` from the UMLS small model. However, when attempting to open the project for annotation, we encounter the following error:

 ![Image](https://europe1.discourse-cdn.com/flex017/uploads/cogstack/original/1X/059ad5cd752bcc19e2242a2b10d45b5d44de93f0.jpeg)

Our understanding is that the project should use the ‘en\_core\_web\_md’ model, as in the config file (`cat.general.spacy_model = 'en_core_web_md'`). The ‘en\_core\_web\_md’ model is downloaded during the container build.

We would appreciate any help in resolving this issue. Thank you

---

<div class="post-metadata">

**Author:** ![tomolopolis](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@tomolopolis](https://discourse.cogstack.org/u/tomolopolis)\
**Post date:** [November 21, 2023, 1:47pm UTC](https://discourse.cogstack.org/t/error-in-medcattrainer-project-setup-missing-spacy-model/246/2 "2023-11-21T13:47:23Z")

</div>

hi @tapak - which trainer release version are you trying to run?

---

<div class="post-metadata">

**Author:** ![tapak](https://avatars.discourse-cdn.com/v4/letter/t/f19dbf/32.png) [@tapak](https://discourse.cogstack.org/u/tapak)\
**Post date:** [November 22, 2023, 6:39am UTC](https://discourse.cogstack.org/t/error-in-medcattrainer-project-setup-missing-spacy-model/246/3 "2023-11-22T06:39:30Z")

</div>

hi  
I’m using v2.12.3

---

<div class="post-metadata">

**Author:** ![andrii.k](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@andrii.k](https://discourse.cogstack.org/u/andrii.k)\
**Post date:** [January 22, 2024, 10:19am UTC](https://discourse.cogstack.org/t/error-in-medcattrainer-project-setup-missing-spacy-model/246/4 "2024-01-22T10:19:39Z")

</div>

Did anyone manage to find fixes for this problem? I am experiencing the same issue

---

<div class="post-metadata">

**Author:** ![mart.ratas](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mart.ratas](https://discourse.cogstack.org/u/mart.ratas)\
**Post date:** [January 22, 2024, 3:54pm UTC](https://discourse.cogstack.org/t/error-in-medcattrainer-project-setup-missing-spacy-model/246/5 "2024-01-22T15:54:43Z")

</div>

I’m fairly certain I know what the issue is.

The earlier `medcat` model packs shipped with a spacy model named simply `spacy_model` within the model pack. The same is specified within the config.  
When the `medcat` library loads the model pack, it modifies the value of `config.general.spacy_model` to point at the to the unpacked model pack folder (currently line 375 of the `medcat.CAT` module).  
However, due to the way MedCATtrainer is built, it only loads the CDB. Not the entire model pack. Thus, this change to the name/path of the spacy model is not done (and wouldn’t be applicable since the `spacy` model wouldn’t be available at that location).

I’ve come up with the following workaround.

- In a python environment with `medcat` installed
- Get this python script: [Update the spacy model name in older MedCAT models that specified it as `spacy_model` - use the default (`en_core_web_md`) instead. Can overwrite existing CDB (1 CLI argument) or write to a new file (2 CLI arguments). · GitHub](https://gist.github.com/mart-r/d853073f1c724aa5345769faea4a869e)
- Run it against the CDB
  - `python update_spacy_model_in_old_cdb.py <cdb_path>` to make the fix and overwrite
  - `python update_spacy_model_in_old_cdb.py <cdb_path> <new_cdb_path>` to write to a new file

What this script does is rename the spacy model from `spacy_model` to `en_core_web_md` (the small UMLS model used the 3.1.0 version of this, but newer ones should also work) and then saves it back to disk. This will allow MCT to successfully load and use the CDB.
