title: Create binary of spaCy with PyInstaller
body: <p>I would like to create a binary of my python code, that contains spaCy.</p>
  <pre class="lang-py prettyprint-override"><code># main.py
  
  import spacy
  import en_core_web_sm
  
  def main() -&gt; None:
      nlp = spacy.load(&quot;en_core_web_sm&quot;)
      # nlp = en_core_web_sm.load()
      doc = nlp(&quot;This is an example&quot;)
      print([(w.text, w.pos_) for w in doc])
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>
  <p>Besides my code, I created two PyInstaller-hooks, as described <a href="https://stackoverflow.com/a/64887390/7988528">here</a></p>
  <p>To create the binary I use the following command <code>pyinstaller main.py --additional-hooks-dir=.</code>.</p>
  <p>On the execution of the binary I get the following error message:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;main.py&quot;, line 19, in &lt;module&gt;
      main()
    File &quot;main.py&quot;, line 12, in main
      nlp = spacy.load(&quot;en_core_web_sm&quot;)
    File &quot;spacy/__init__.py&quot;, line 47, in load
    File &quot;spacy/util.py&quot;, line 329, in load_model
  OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a Python package or a valid path to a data directory.
  </code></pre>
  <p>If I use <code>nlp = en_core_web_sm.load()</code> instead if <code>nlp = spacy.load(&quot;en_core_web_sm&quot;)</code> to load the spacy model, I get the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;main.py&quot;, line 19, in &lt;module&gt;
      main()
    File &quot;main.py&quot;, line 13, in main
      nlp = en_core_web_sm.load()
    File &quot;en_core_web_sm/__init__.py&quot;, line 10, in load
    File &quot;spacy/util.py&quot;, line 514, in load_model_from_init_py
    File &quot;spacy/util.py&quot;, line 389, in load_model_from_path
    File &quot;spacy/util.py&quot;, line 426, in load_model_from_config
    File &quot;spacy/language.py&quot;, line 1662, in from_config
    File &quot;spacy/language.py&quot;, line 768, in add_pipe
    File &quot;spacy/language.py&quot;, line 659, in create_pipe
    File &quot;thinc/config.py&quot;, line 722, in resolve
    File &quot;thinc/config.py&quot;, line 771, in _make
    File &quot;thinc/config.py&quot;, line 826, in _fill
    File &quot;thinc/config.py&quot;, line 825, in _fill
    File &quot;thinc/config.py&quot;, line 1016, in make_promise_schema
    File &quot;spacy/util.py&quot;, line 137, in get
  catalogue.RegistryError: [E893] Could not find function 'spacy.Tok2Vec.v1' in function registry 'architectures'. If you're using a custom function, make sure the code is available. If the function is provided by a third-party package, e.g. spacy-transformers, make sure the package is installed in your environment.
  </code></pre>