I have an application that analyses text looking for keywords using natural language processing. I created an executable and it works fine on my computer. I’ve sent it to a friend but in his computer he gets an error:
Traceback (most recent call last): File "Main.py", line 15, in <module> File "Menu.py", line 349, in main_menu File "Menu.py", line 262, in analyse_text_menu File "Menu.py", line 178, in analyse_text_function File "AnalyseTextProcessText.py", line 232, in process_text File "AnalyseTextProcessText.py", line 166, in generate_keyword_complete_list File "AnalyseTextProcessText.py", line 135, in lemmatize_text File "stanzapipelinecore.py", line 88, in _init_ stanza.pipeline.core.ResourcesFileNotFoundError: Resources file not found at: C:Usersjpovoasstanza_resourcesresources.json Try to download the model again.  Failed to execute script 'Main' due to unhandled exception!
It’s looking for
resources.json inside a folder in his computer. Even though I’ve added
stanza as a hidden import with pyinstaller.
I’m using a model in another language, as opposed to the default one in english. The model is located in a folder inside the User folder.
The thing is, I don’t want the end user to have to download the model separatedly.
I’ve managed to include the model folder with
--add-data C:UsersLailastanza_resourcespt;Stanza" when creating the executable.
It still looks for the model’s json file inside the
stanza_resources folder that’s should be inside the User folder of whoever is using the program.
How do I tell stanza to look for the model inside the executable folder generated instead?
Can I just add
stanza.download("language") in my script? If so how do I change stanza’s model download folder? I want it to be downloaded into a folder inside the same directory as the executable. How do I do that?
Edit: It would be possible to change the location of the model download by doing the following:
It wouldn’t be the ideal solution for me though, because I’d like to avoid having to download the model again.
I solved it by passing a value to the
model_dir argument when making a pipeline:
npl = stanza.Pipeline(lang='Pt', model_dir='.\Stanza')
Inside the folder called Stanza I’ve placed both the model folder (in this case “pt”) and the resources.json file.