简体   繁体   中英

Pandas Python Not found module - Azure devops Flask App CI/CD Pipeline

I am trying to Build a Flask App using Azure Devops and i followed this link

https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python-webapp?view=azure-devops

I am able to the build and deploy sample application successfully.

在此处输入图片说明

But when i am adding additional packages in requirements.txt and push it to Azure repo. The .yaml file is running automatically but in the build stage all the packages are getting install and i am not getting any error during the pipeline stage and deployment stage but when i try to test the application, It is showing package not found error. I have not changed anything in .yaml file

# Python to Linux Web App on Azure
# Build your Python project and deploy it to Azure as a Linux Web App.
# Change python version to one thats appropriate for your application.
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
trigger:
- master
variables:
  # Azure Resource Manager connection created during pipeline creation
  azureServiceConnectionId: '#############'
  
  # Web app name
  webAppName: 'flaskappdemo2'
  # Agent VM image name
  vmImageName: 'ubuntu-latest'
  # Environment name
  environmentName: 'flaskappdemo2'
  # Project root folder. Point to the folder containing manage.py file.
  projectRoot: $(System.DefaultWorkingDirectory)
  
  # Python version: 3.6
  pythonVersion: '3.6'
stages:
- stage: Build
  displayName: Build stage
  jobs:
  - job: BuildJob
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: UsePythonVersion@0
      inputs:
        versionSpec: '$(pythonVersion)'
      displayName: 'Use Python $(pythonVersion)'
    
    - script: |
        python -m venv antenv
        source antenv/bin/activate
        python -m pip install --upgrade pip
        pip install setup
        pip install -r requirements.txt
      workingDirectory: $(projectRoot)
      displayName: "Install requirements"
    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(projectRoot)'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true
    - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      displayName: 'Upload package'
      artifact: drop
- stage: Deploy
  displayName: 'Deploy Web App'
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: DeploymentJob
    pool:
      vmImage: $(vmImageName)
    environment: $(environmentName)
    strategy:
      runOnce:
        deploy:
          steps:
          
          - task: UsePythonVersion@0
            inputs:
              versionSpec: '$(pythonVersion)'
            displayName: 'Use Python version'
          - task: AzureWebApp@1
            displayName: 'Deploy Azure Web App : flaskappdemo2'
            inputs:
              azureSubscription: $(azureServiceConnectionId)
              appName: $(webAppName)
              package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
              startUpCommand: 'gunicorn --bind=0.0.0.0 --workers=4 startup:app'

These are the logs:

在此处输入图片说明

Came across this post where they have activated the virtual environment - make sure to check if your installed package is actually in there in your VENV and adding WEBSITE_RUN_FROM_PACKAGE = 1 to the web app !

Reference Post

This issue happens when a Python Function App is unable to load a Python module. This can be extended to your scenario

  1. The package can't be found
  2. The package isn't resolved with proper Linux wheel
  3. The package is incompatible with the Python interpreter version
  4. The package conflicts with other packages
  5. The package only supports Windows or macOS platforms (Y ou can safely ignore this option)

You could refer this article further isolate the cause from here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM