[2023-04-27T08:21:37.499Z] Executing 'Functions.func-test' (Reason='This function was programmatically called via the host APIs.', Id=44347c87-36a7-4415-bbe8-63a922af57bc)
[2023-04-27T08:21:37.590Z] Executed 'Functions.func-test' (Failed, Id=44347c87-36a7-4415-bbe8-63a922af57bc, Duration=125ms)
[2023-04-27T08:21:37.591Z] System.Private.CoreLib: Exception while executing function: Functions.func-test. System.Private.CoreLib: Result: Failure
Exception: ModuleNotFoundError: No module named 'pandas'. Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound
Stack: File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 357, in _handle__function_load_request
func = loader.load_function(
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\azure_functions_worker\utils\wrappers.py", line 48, in call
raise extend_exception_message(e, message)
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\azure_functions_worker\utils\wrappers.py", line 44, in call
return func(*args, **kwargs)
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.10/WINDOWS/X64\azure_functions_worker\loader.py", line 132, in load_function
mod = importlib.import_module(fullmodname)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\anandu.balachandran\AzureFunctionTest\func-test\__init__.py", line 3, in <module>
import pandas as pd
示例代码
import logging
import azure.functions as func
import pandas as pd
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
requirements.txt中提到了pandas lib
当代码部署到函数应用程序时,它的工作
但是在尝试调试本地中的代码时,它不起作用 - 可以看到 pandas 在 Debug模式下安装,如果 pandas import 被删除,我可以调试代码并使用 postman 触发 http 请求(仅与 pandas 包有关的问题)
我的requirements.txt 文件包含
pandas==2.0.1
numpy
azure-functions
azure-storage-blob
openai[embeddings]
requests
最佳答案
我尝试在我的环境中重现相同的情况,但 Pandas 模块出现相同的错误。
可能是因为本地环境中没有正确安装pandas
模块。
运行以下命令并检查它是否有助于解决问题。它对我有用:
pip install -r requests.txt
。
结果:
然后尝试调试并检查问题是否仍然存在。
关于python - Azure 函数 ModuleNotFoundError : No module named 'pandas' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76118380/