繁体   English   中英

Azure 功能 Python 状态:500 内部服务器错误

[英]Azure Functions Python Status: 500 Internal Server Error

Exception: ModuleNotFoundError: No module named 'pandas'
Stack:   File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/dispatcher.py", line 242, in _handle__function_load_request
    func_request.metadata.entry_point)
  File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/loader.py", line 66, in load_function
    mod = importlib.import_module(fullmodname)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/site/wwwroot/HttpExample/__init__.py", line 9, in <module>
    import pandas as pd

在线运行时,我在 Azure 函数上收到此错误。 有一个 requirements.txt 文件,其中包含 pandas 要求,但它仍然设法找不到模块名称 pandas。 在本地 function 工作正常。

根据评论中的对话,我不确定问题是什么。 但是我发布了我刚才所做的所有步骤供您参考,我按照以下步骤操作,它没有显示有关导入 pandas 的错误消息。

  1. 我在 VS Code 中创建了一个 python function 并运行以下命令在本地安装 pandas。
pip install pandas

在此处输入图像描述

然后在主代码中添加代码“import pandas as pd”并调用pad。 在此处输入图像描述

  1. 运行以下命令以自动生成“requirements.txt”。
pip freeze > requirements.txt

在此处输入图像描述

运行此命令后,我的“requirements.txt”显示如下:

在此处输入图像描述

  1. Crate a function app(python) on azure portal with the name of "hurypyfun" and run the command below in VS code TERMINAL to deploy the function from local to azure.
func azure functionapp publish hurypyfun --build remote

在此处输入图像描述

  1. 稍等几分钟,部署完成后我们可以在 azure 门户上进行测试。 它显示成功,但不显示有关导入 pandas 的错误消息。 在此处输入图像描述

希望对你的问题有所帮助~

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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