无法在python azure函数中导入pyodbc模块

问题描述 投票:0回答:1

我正在编写python azure函数。为简单起见,我使用如下示例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

我正在编写python azure函数。为简单起见,我使用如下示例Python函数。我在vscode中开发了该函数,并尝试在本地计算机上对其进行测试。天蓝色...

python azure azure-functions pyodbc
1个回答
0
投票

复制OP的评论中的答案作为解决方法:

© www.soinside.com 2019 - 2024. All rights reserved.