Azure DevOps AzureFunctionApp@1 未安装 python 依赖项
Azure DevOps AzureFunctionApp@1 not installing python dependencies
在当前设置下使用 Azure Devops 任务:
task: AzureFunctionApp@1
displayName: Deploy Lab
inputs:
azureSubscription: 'serviceConnection'
appType: 'functionAppLinux'
appName: 'myAwesomeApp'
package: '.'
runtimeStack: 'PYTHON|3.8'
此外,在根目录中(即ado任务中的.
),我有一个requirements.txt文件,其中包含numpy
部署 运行 成功,但是当我测试应用程序时,出现以下错误:
Failure Exception: ModuleNotFoundError: No module named 'numpy'
这只是意味着未考虑 requirements.txt 文件或 pip install -r requirements.txt 没有 运行 在远程计算中成功,我做错了什么?
编辑:添加了一个在本地安装包的步骤确实有效,但由于 numpy 是一个 C 构建的库,它依赖于主机并且在远程函数应用程序中不起作用:lol:
我添加的步骤是这一步:
- bash: pip install -r requirements.txt --target="./.python_packages/lib/site-packages"
displayName: 'Install dependencies'
错误:
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)
也许您将不得不使用 python 3.9 和管道中的最新 ubuntu 代理
https://github.com/Azure/azure-functions-python-worker/issues/904
在当前设置下使用 Azure Devops 任务:
task: AzureFunctionApp@1
displayName: Deploy Lab
inputs:
azureSubscription: 'serviceConnection'
appType: 'functionAppLinux'
appName: 'myAwesomeApp'
package: '.'
runtimeStack: 'PYTHON|3.8'
此外,在根目录中(即ado任务中的.
),我有一个requirements.txt文件,其中包含numpy
部署 运行 成功,但是当我测试应用程序时,出现以下错误:
Failure Exception: ModuleNotFoundError: No module named 'numpy'
这只是意味着未考虑 requirements.txt 文件或 pip install -r requirements.txt 没有 运行 在远程计算中成功,我做错了什么?
编辑:添加了一个在本地安装包的步骤确实有效,但由于 numpy 是一个 C 构建的库,它依赖于主机并且在远程函数应用程序中不起作用:lol:
我添加的步骤是这一步:
- bash: pip install -r requirements.txt --target="./.python_packages/lib/site-packages"
displayName: 'Install dependencies'
错误:
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)
也许您将不得不使用 python 3.9 和管道中的最新 ubuntu 代理
https://github.com/Azure/azure-functions-python-worker/issues/904