如何在 Google 云函数中使用 pyodbc 库?
How to use pyodbc library in a Google Cloud Function?
我正在尝试在使用 pyodbc
模块时使用 Python 3.8 Beta 作为运行时来实现 Google 云函数。我在尝试实施时遇到错误。
据我通过阅读其他 Stack Overflow 问题了解到,要在 linux 发行版上使用 pyodbc
,您需要 sudo install some things before you can use pyodbc
as it需要一些 OS 特定资源。
有没有人知道如何做到这一点或知道另一种使 pyodbc
在 Google 云函数中工作的方法?
执行错误google 云函数正在抛出:
Build failed: ...: sql.h: No such file or directory
#include <sql.h>
^~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pyodbc
Building wheel for pyodbc (setup.py): finished with status 'error'
Running setup.py clean for pyodbc
Successfully built ftputil
Failed to build pyodbc
Installing collected packages: pytz, six, python-dateutil, numpy, pandas, ftputil, pyodbc, setuptools, zope.interface, datetime
Running setup.py install for pyodbc: started
Running setup.py install for pyodbc: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /opt/python3.8/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-np63kzip/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-np63kzip/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-2ijqo8fi/install-record.txt --single-version-externally-managed --home /tmp/pip-target-3prwz462 --compile --install-headers /tmp/pip-target-3prwz462/include/python/pyodbc
cwd: /tmp/pip-install-np63kzip/pyodbc/
Complete output (14 lines):
running install
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fstack-protector-strong -g -Wformat -Werror=format-security -fPIC -DPYODBC_VERSION=4.0.30 -I/opt/python3.8/include/python3.8 -c src/buffer.cpp -o build/temp.linux-x86_64-3.8/src/buffer.o -Wno-write-strings
In file included from src/buffer.cpp:12:0:
src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
#include <sql.h>
^~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
这不可能。 pyodbc
项目 requires the unixobdc-dev
platform package, which is not in the list of system packages included in the Cloud Functions runtime.
相反,您可能想要使用 Cloud Run,它允许您定义自己的运行时并安装您想要的任何平台包。
我正在尝试在使用 pyodbc
模块时使用 Python 3.8 Beta 作为运行时来实现 Google 云函数。我在尝试实施时遇到错误。
据我通过阅读其他 Stack Overflow 问题了解到,要在 linux 发行版上使用 pyodbc
,您需要 sudo install some things before you can use pyodbc
as it需要一些 OS 特定资源。
有没有人知道如何做到这一点或知道另一种使 pyodbc
在 Google 云函数中工作的方法?
执行错误google 云函数正在抛出:
Build failed: ...: sql.h: No such file or directory
#include <sql.h>
^~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pyodbc
Building wheel for pyodbc (setup.py): finished with status 'error'
Running setup.py clean for pyodbc
Successfully built ftputil
Failed to build pyodbc
Installing collected packages: pytz, six, python-dateutil, numpy, pandas, ftputil, pyodbc, setuptools, zope.interface, datetime
Running setup.py install for pyodbc: started
Running setup.py install for pyodbc: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /opt/python3.8/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-np63kzip/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-np63kzip/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-2ijqo8fi/install-record.txt --single-version-externally-managed --home /tmp/pip-target-3prwz462 --compile --install-headers /tmp/pip-target-3prwz462/include/python/pyodbc
cwd: /tmp/pip-install-np63kzip/pyodbc/
Complete output (14 lines):
running install
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fstack-protector-strong -g -Wformat -Werror=format-security -fPIC -DPYODBC_VERSION=4.0.30 -I/opt/python3.8/include/python3.8 -c src/buffer.cpp -o build/temp.linux-x86_64-3.8/src/buffer.o -Wno-write-strings
In file included from src/buffer.cpp:12:0:
src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
#include <sql.h>
^~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
这不可能。 pyodbc
项目 requires the unixobdc-dev
platform package, which is not in the list of system packages included in the Cloud Functions runtime.
相反,您可能想要使用 Cloud Run,它允许您定义自己的运行时并安装您想要的任何平台包。