need to install spacy model in azure webapp Linux python 3.8

Kesavamurthi D 126 Reputation points
2023-02-21T19:28:12.5066667+00:00

hi

we need to have spacy models in python azure webapps .linux

python -m spacy download en_core_web_trf  

python -m spacy download en_core_web_sm

how to load it while running it or in startup .or how to mention it in requirement.txt

pls help

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2023-02-22T06:03:53.74+00:00

    Hi @Kesavamurthi D

    I haven't tried using https://github.com/explosion/spacy-models/releases/download/en_core_web_trf-3.4.0/en_core_web_trf-3.4.0.tar.gz but if you're seeing installation failures when your app is being setup, then I suggest doing one of the following options:

    1. Add a post deployment script that will run python -m spacy download en_core_web_sm after your application has finished installation. This assumes you have you SCM_DO_BUILD_DURING_DEPLOYMENT set to true on the app service.
    2. Create a local app directory folder and extract the en_core_web_trf model and include that directory with your deployment. Still include spacy in your requirements.txt and in your python code, reference that folder i.e. spacy.load('<local-folder>/en_core_web_trf-3.4.0')

    If you have an issue with one of above workarounds, please comment down below.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.