none
Azure Python Deployment - Spacy nomodule found exception RRS feed

  • Question

  • I'm using Linux App Service. I'm trying to deploy python 3.6 flask application through the Azure DevOps pipeline. It worked fine for a basic app but when I add an additional code (spacy module), it started to throw


        2019-12-24T18:07:33.079953940Z     __import__(module)
        2019-12-24T18:07:33.079961840Z   File "/home/site/wwwroot/application.py", line 3, in <module>
        2019-12-24T18:07:33.079970340Z     from Data_Cleanup_utility.clear_content_utility import ClearContent
        2019-12-24T18:07:33.079978440Z   File "/home/site/wwwroot/Data_Cleanup_utility/clear_content_utility.py", line 12, in <module>
        2019-12-24T18:07:33.079986741Z     import spacy
        2019-12-24T18:07:33.079994741Z **ModuleNotFoundError: No module named 'spacy'**
        2019-12-24T18:07:33.084726683Z [2019-12-24 18:07:33 +0000] [51] [INFO] Worker exiting (pid: 51)
        2019-12-24T18:07:33.170423056Z [2019-12-24 18:07:33 +0000] [48] [INFO] Shutting down: Master
        2019-12-24T18:07:33.172257711Z [2019-12-24 18:07:33 +0000] [48] [INFO] Reason: Worker failed to boot.


    I have added the dependency modules in the **requirement.txt**

        Flask==1.0.2
        Flask-Cors==3.0.8
        Flask-RESTful==0.3.7
        fastai==1.0.59
        numpy==1.17.4
        pandas==0.25.3
        requests==2.22.0
        spacy==2.2.3
        spacy-langdetect==0.1.2

    and **azurepipeline.yml**

        - script: |
                python -m venv antenv
                source antenv/bin/activate
                python -m pip install --upgrade pip
                pip install setup
                pip install -r requirements.txt
                python -m spacy download es
              workingDirectory: $(projectRoot)
              displayName: "Install requirements"

    and my code **clear_content_utility.py**

        import spacy
        from spacy_langdetect import LanguageDetector
        
        nlp = spacy.load('es')
        nlp.add_pipe(LanguageDetector(), name='language_detector', last=True)

    did anyone face the above issue? appreciate your help. 
    Tuesday, December 24, 2019 6:23 PM

Answers