【发布时间】:2021-10-31 20:25:00
【问题描述】:
我创建了一个本地 azure linux 函数并使用func start 成功测试。测试后 Azure Devops Pipe Line 将其提升为 Azure (Linux) Function。部署似乎是有序的。
在 Azure (Linux) 功能测试期间查看监控返回以下错误:
结果:失败异常:ModuleNotFoundError: No module named 'pyodbc'。故障排除指南: https://aka.ms/functions-modulenotfound 堆栈:文件 "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py", 第 305 行,在 _handle__function_load_request func = loader.load_function( 文件 "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", 第 42 行,调用 raise extend_exception_message(e, message) 文件 "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/utils/wrappers.py", 第 40 行,在调用中返回 func(*args, **kwargs) 文件 "/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/loader.py", 第 85 行,在 load_function mod = importlib.import_module(fullmodname) 文件“/usr/local/lib/python3.9/importlib/init.py”,第 127 行,在 import_module return _bootstrap._gcd_import(name[level:], package, 级别)文件“/home/site/wwwroot/get_nji_metadata/init.py”,第 3 行, 从 .Metadata 导入元数据文件 “/home/site/wwwroot/get_nji_metadata/Metadata.py”,第 2 行,在 导入pyodbc
Requirements.txt
astroid==2.4.2
azure-functions==1.2.1
certifi==2020.6.20
chardet==3.0.4
colorama==0.4.3
idna==2.9
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
pylint==2.5.3
pyodbc==4.0.30
requests==2.24.0
six==1.15.0
toml==0.10.1
urllib3==1.25.9
wrapt==1.12.1
问题
- 有没有办法在“Linux 变体”中解决这个问题。我已经看过Linux Python Azure Function APP - pyodbc module not found despite being in requirements.txt and other modules working fine 但不明白这个人的解决方案。还查看了 Microsoft 文档。
- 我是否在 Azure Functions 的“Windows 变体”上解决了这个问题?
请帮帮我?
谢谢埃里克
【问题讨论】:
-
Pyodbc 是出了名的烦人。你能偶然在 Linux 上安装其他软件包吗?问题将通过 sudo apt installs 解决,而不是通过 pip。
-
如何使用 azure 功能进行 apt-install?
-
在运行命令
func start或func host start之前,你是否运行了这两个命令pip freeze > requirements.txt,然后在激活它pip install -r requirements.txt之后在虚拟环境中安装库并运行主命令@ 987654331@并检查它。