Я пытаюсь запустить свой сценарий python на Служба Azure ML для извлечения данных из База данных SQL Azure с использованием библиотеки pyodbc .
Пожалуйста, проверьте код ниже:
import pyodbc
class AzureDbConnect:
# This class is used for azure database connection using pyodbc
def __init__(self):
try:
self.sql_db = pyodbc.connect('DRIVER={SQL SERVER};SERVER=<servername>;PORT=1433;DATABASE=<databasename>;UID=<username>;PWD=<password>')
get_name_query = "select name from contacts"
names = self.sql_db.execute(get_name_query)
for name in names:
print(name)
except Exception as e:
print("Error in azure sql server database connection : ", e)
sys.exit()
class_obj = AzureDbConnect()
При запуске этого кода на azure ml service затем azure ml эксперимент не удался и с ошибкой ниже в журналах:
Running setup.py install for pyodbc: started
Running setup.py install for pyodbc: finished with status 'error'
[91m ERROR: Command errored out with exit status 1:
command: /azureml-envs/azureml_9d69e3c489cf5128837b0d54c6aae18e/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-zggh4t5x/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-zggh4t5x/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-hx3xndx9/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-zggh4t5x/pyodbc/
Complete output (13 lines):
running install
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPYODBC_VERSION=4.0.27 -I/azureml-envs/azureml_9d69e3c489cf5128837b0d54c6aae18e/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x86_64-3.6/src/buffer.o -Wno-write-strings
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from src/buffer.cpp:12:0:
src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Как исправить эту ошибку?