For those struggling with the same issue. Change the pip install
line as follows
pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I've been struggling with this problem for the past few days. I have Python 3.9 code and an Azure DevOps pipeline where it builds and deploy the code to Azure Functions.
The pipeline has been working fine for the past several weeks (it's new) and there was no deployment recently until I had to fix a few lines of code, then I pushed to Azure Repo which triggers the pipeline. But this time the Function crashed after deployment; this is the error message:
Exception: ModuleNotFoundError: No module named 'holidays'. Cannot find module. Please check the requirements.txt file for the missing module.
This is my requirements.txt file, which clearly states the holidays module version.
azure-functions
azure-functions-durable
azure-identity==1.14.0
azure-keyvault-secrets==4.7.0
azure-storage-blob==12.17.0
dotmap==1.3.30
holidays==0.32
json5==0.9.14
numpy==1.25.2
pandas==2.1.0
pyodbc==4.0.39
pytz==2023.3.post1
requests_oauthlib==1.3.1
sqlalchemy==2.0.20
When I deploy from VS Code using Azure Functions extension, the code runs fine without any error, so I'm suspecting that the DevOps pipeline is acting weird (despite nobody changed anything on the YAML file)
This is my azure-pipelines.yml file
trigger:
- main
variables:
azureSubscription: '<REDACTED>'
functionAppName: <REDACTED>
functionAppProjectPath: $(System.DefaultWorkingDirectory)/
pythonVersion: '3.9'
vmImage: ubuntu-latest
stages:
- stage: Build
displayName: Build Stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImage)
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: $(pythonVersion)
- bash: |
pip install -r requirements.txt
workingDirectory: $(functionAppProjectPath)
displayName: 'Install dependencies'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: $(functionAppProjectPath)
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true
- publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop
- stage: Deploy
displayName: Deploy Stage
dependsOn: Build
condition: succeeded()
jobs:
- deployment: Deploy
displayName: Deploy
environment: <REDACTED>
pool:
vmImage: $(vmImage)
strategy:
runOnce:
deploy:
steps:
- task: AzureFunctionApp@2
displayName: 'Azure Function App Deploy'
inputs:
appType: functionAppLinux
appName: $(functionAppName)
azureSubscription: $(azureSubscription)
package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
For those struggling with the same issue. Change the pip install
line as follows
pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt