Home > Software design >  Azure DevOps AzureFunctionApp@1 not installing python dependencies
Azure DevOps AzureFunctionApp@1 not installing python dependencies

Time:03-22

Using the Azure Devops task with current setup :

 task: AzureFunctionApp@1
  displayName: Deploy Lab
  inputs:
    azureSubscription: 'serviceConnection'
    appType: 'functionAppLinux'
    appName: 'myAwesomeApp'
    package: '.'
    runtimeStack: 'PYTHON|3.8'

Also, in the root directory (ie . in the ado task), I have a requirements.txt file that contains numpy

The deployment runs successfully but when I test the app, I have the following error:

Failure Exception: ModuleNotFoundError: No module named 'numpy'

Which simply means that the requirements.txt file is not considered or pip install -r requirements.txt didn't run successfully in the remote compute, what am I doing wrong ?

EDIT: Added a step to install the packages locally did work, but as numpy is a C built library it's dependent on the host machine and that doesn't work in the remote function app :lol:

The step that I added is this one:

- bash: pip install -r requirements.txt --target="./.python_packages/lib/site-packages"
  displayName: 'Install dependencies'

And the error:

Result: Failure Exception: ImportError: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.html Please note and check the following: * The Python version is: Python3.9 from "/usr/local/bin/python" * The NumPy version is: "1.22.3" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: No module named 'numpy.core._multiarray_umath' . Troubleshooting Guide: https://aka.ms/functions-modulenotfound Stack: File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", line 305, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 42, in call raise extend_exception_message(e, message) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 40, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/loader.py", line 85, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1030, in _gcd_import File "", line 1007, in _find_and_load File "", line 986, in _find_and_load_unlocked File "", line 680, in _load_unlocked File "", line 850, in exec_module File "", line 228, in _call_with_frames_removed File "/home/site/wwwroot/bilans/main.py", line 24, in from . import bilan File "/home/site/wwwroot/bilans/bilan.py", line 16, in import numpy as np File "/home/site/wwwroot/.python_packages/lib/site-packages/numpy/init.py", line 144, in from . import core File "/home/site/wwwroot/.python_packages/lib/site-packages/numpy/core/init.py", line 49, in raise ImportError(msg)

CodePudding user response:

Maybe you will have to use python 3.9 and the latest ubuntu agent in the pipeline

https://github.com/Azure/azure-functions-python-worker/issues/904

  • Related