python - 无法在 python azure 函数中导入 pyodbc 模块
问题描述
我正在编写一个 python 天蓝色函数。为简单起见,我使用如下示例 python 函数。
我在我的 vscode 中开发了这个功能,并试图在我的本地机器上测试它。天蓝色功能启动失败。它抛出错误说 failed to import pyodbc
。
import pyodbc
但是,当我更改为import pandas
sklearn、numpy 等其他模块时没有问题。所以我很确定问题来自模块 pyodbc。
有没有人有同样的问题?如何解决这个问题?我不知道...非常感谢。
这是天蓝色的功能:
import logging
import azure.functions as func
# it works when I import other modules like pandas, sklearn, etc
import pyodbc
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}!")
else:
return func.HttpResponse(
"Please pass a name on the query string or in the request body",
status_code=400
)
这是我的要求.txt
azure-functions
pyodbc
#pandas
#numpy
#sklearn
解决方案
推荐阅读
- mysql - SQL 默认值当前日期和时间
- python - 有没有办法在 Python 中绕过很长的解析字节字符串?/ to_html
- excel - 如何在excel的一个单元格中显示平均+标准偏差参数
- python - 时间数据“2019-06-02T16:19:27.000-04:00”与格式“%Y-%m-%dT%H:%M:%S.%fZ”不匹配
- java - 加密用户密码android studio
- wordpress - WordPress 标记错误地显示在页面中
- reactjs - 反应问题:错误:超过最大更新深度
- c++ - 如何在不依赖注入的情况下模拟遗留函数?
- django - 如何在 Django rest 序列化程序输出旁边返回用户会话 ID
- x86 - 分页命名法