简体   繁体   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

I get this error on Azure Functions when run online.在线运行时,我在 Azure 函数上收到此错误。 There is a requirements.txt file which contains the pandas requirement but it still manages to not find the module name pandas.有一个 requirements.txt 文件,其中包含 pandas 要求,但它仍然设法找不到模块名称 pandas。 Locally the function works fine.在本地 function 工作正常。

According to the conversation in comments, I'm not sure what the problem is.根据评论中的对话,我不确定问题是什么。 But I post all of the steps I did just now for your reference, I follow the steps below and it didn't show the error message about import pandas.但是我发布了我刚才所做的所有步骤供您参考,我按照以下步骤操作,它没有显示有关导入 pandas 的错误消息。

  1. I create a python function in VS Code and run the command below to install pandas in local.我在 VS Code 中创建了一个 python function 并运行以下命令在本地安装 pandas。
pip install pandas

在此处输入图像描述

Then add the code "import pandas as pd" and call the pad in the main code.然后在主代码中添加代码“import pandas as pd”并调用pad。 在此处输入图像描述

  1. Run the command below to generate "requirements.txt" automatically.运行以下命令以自动生成“requirements.txt”。
pip freeze > requirements.txt

在此处输入图像描述

After run this command, my "requirements.txt" show as below:运行此命令后,我的“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. 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. Wait a few minutes, after the deployment we can test it on azure portal.稍等几分钟,部署完成后我们可以在 azure 门户上进行测试。 It shows success and it doesn't show the error message about import pandas.它显示成功,但不显示有关导入 pandas 的错误消息。 在此处输入图像描述

Hope it would be helpful to your problem~希望对你的问题有所帮助~

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

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