本文介绍了如何在Azure Machine Learning Workbench中使用Pyodbc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试使用pyodbc在Azure ML Workbench中导入数据框.这在本地运行中有效,但不适用于docker.尝试建立与SQL Server的连接时失败,因为该驱动程序不存在.

I'm trying to use pyodbc to import a dataframe in Azure ML Workbench. This works in local runs, but not for docker. It fails when trying to establish a connection to the SQL Server, because the driver is not present.

cnxn = pyodbc.connect('DRIVER='{ODBC Driver 13 for SQL Server}';PORT=1433;SERVER='+server+';PORT=1443;DATABASE='+database+';UID='+username+';PWD='+ password)

错误消息:

在寻找解决方案时,我发现我可以将这些行放入docker文件中

When searching for a solution i found that i could put these lines in the docker file

运行apt-get更新

RUN apt-get update

运行apt-get install -y tdsodbc unixodbc-dev

RUN apt-get install -y tdsodbc unixodbc-dev

运行apt install unixodbc-bin -y

RUN apt install unixodbc-bin -y

运行apt-get clean -y

RUN apt-get clean -y

但是,我是docker的新手,无法弄清楚将这些行放在ML Workbench中的位置.似乎docker文件是通过 docker.compute conda_dependencies.yml 生成的,但是在解决方案中的任何一项或其他内容中都找不到与上述类似的内容

However I'm new to docker, and cannot figure out where to put these lines in the ML Workbench. It seems the docker file is generated through docker.compute and conda_dependencies.yml, but nothing similar to the lines above can be found in either of those or anywere else in the solution.

推荐答案

您可以构建具有所需依赖项的docker映像,并在docker.compute文件中指定映像名称:

You can build docker image with dependencies you need and specify your image name inside the docker.compute file:

baseDockerImage:<your docker image name>

我创建了 azml_pyodbc图片,您可以尝试将其用于:

I created azml_pyodbc image,you can try to use it with:

baseDockerImage: "aksanakuzmitskaya/azml_pyodbc:firsttry"
DRIVER='{ODBC Driver 17 for SQL Server}'

这篇关于如何在Azure Machine Learning Workbench中使用Pyodbc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 21:39