【问题标题】:How to deploy python dash app with pyodbc on heroku如何在heroku上使用pyodbc部署python dash应用程序
【发布时间】:2021-04-15 05:17:18
【问题描述】:

我已经成功地在 heroku 上部署了一些基本的 dash 应用程序:

Windows 10 专业版 x64

Python 3.8

requirements.txt 中的包:

Brotli==1.0.9
click==7.1.2
dash==1.16.0
dash-core-components==1.12.0
dash-html-components==1.1.1
dash-renderer==1.8.0
dash-table==4.10.1
Flask==1.1.2
Flask-Compress==1.8.0
future==0.18.2
gunicorn==20.0.4
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
numpy==1.19.1
pandas==1.0.0
plotly==4.10.0
python-dateutil==2.8.1
pytz==2020.5
retrying==1.3.3
six==1.15.0
Werkzeug==1.0.1

当我安装pip install pyodbc 时,将其添加到requrements.txt 并尝试再次部署我得到一个错误(在本地它工作正常):

(venv) C:\Users\007\PycharmProjects\pythonProject4_38>git push heroku master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 295 bytes | 295.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Requirements file has been changed, clearing cached dependencies
remote: -----> Installing python-3.6.12
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:        Collecting Brotli==1.0.9
remote:          Downloading Brotli-1.0.9-cp36-cp36m-manylinux1_x86_64.whl (357 kB)
remote:        Collecting click==7.1.2
remote:          Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
remote:        Collecting dash==1.16.0
remote:          Downloading dash-1.16.0.tar.gz (72 kB)
remote:        Collecting dash-core-components==1.12.0
remote:          Downloading dash_core_components-1.12.0.tar.gz (3.4 MB)
remote:        Collecting dash-html-components==1.1.1
remote:          Downloading dash_html_components-1.1.1.tar.gz (188 kB)
remote:        Collecting dash-renderer==1.8.0
remote:          Downloading dash_renderer-1.8.0.tar.gz (950 kB)
remote:        Collecting dash-table==4.10.1
remote:          Downloading dash_table-4.10.1.tar.gz (1.8 MB)
remote:        Collecting Flask==1.1.2
remote:          Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
remote:        Collecting Flask-Compress==1.8.0
remote:          Downloading Flask_Compress-1.8.0-py3-none-any.whl (7.2 kB)
remote:        Collecting future==0.18.2
remote:          Downloading future-0.18.2.tar.gz (829 kB)
remote:        Collecting gunicorn==20.0.4
remote:          Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
remote:        Collecting itsdangerous==1.1.0
remote:          Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
remote:        Collecting Jinja2==2.11.2
remote:          Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
remote:        Collecting MarkupSafe==1.1.1
remote:          Downloading MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (27 kB)
remote:        Collecting numpy==1.19.1
remote:          Downloading numpy-1.19.1-cp36-cp36m-manylinux2010_x86_64.whl (14.5 MB)
remote:        Collecting pandas==1.0.0
remote:          Downloading pandas-1.0.0-cp36-cp36m-manylinux1_x86_64.whl (10.1 MB)
remote:        Collecting plotly==4.10.0
remote:          Downloading plotly-4.10.0-py2.py3-none-any.whl (13.0 MB)
remote:        Collecting pyodbc==4.0.30
remote:          Downloading pyodbc-4.0.30.tar.gz (266 kB)
remote:        Collecting python-dateutil==2.8.1
remote:          Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
remote:        Collecting pytz==2020.5
remote:          Downloading pytz-2020.5-py2.py3-none-any.whl (510 kB)
remote:        Collecting retrying==1.3.3
remote:          Downloading retrying-1.3.3.tar.gz (10 kB)
remote:        Collecting six==1.15.0
remote:          Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
remote:        Collecting Werkzeug==1.0.1
remote:          Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
remote:        Building wheels for collected packages: dash, dash-core-components, dash-html-components
, dash-renderer, dash-table, future, pyodbc, retrying
remote:          Building wheel for dash (setup.py): started
remote:          Building wheel for dash (setup.py): finished with status 'done'
remote:          Created wheel for dash: filename=dash-1.16.0-py3-none-any.whl size=82326 sha256=1f887c
fb91f05a19239b59ccf90b1121d54f522ac664f7159ce9e8e39079c599
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-szw5gfg5/wheels/27/eb/db/c0b2c44cb5418
e31c872c435cb39123654229ce425e10282b0
remote:          Building wheel for dash-core-components (setup.py): started
remote:          Building wheel for dash-core-components (setup.py): finished with status 'done'
remote:          Created wheel for dash-core-components: filename=dash_core_components-1.12.0-py3-none-
any.whl size=3478746 sha256=1a838b82ad3ae1b800f1c930fccafc61d18e7eb1c350392110e8d7221066384f
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-szw5gfg5/wheels/18/71/84/1d7c538fb95fe
c74bc2f854a38e96e0ec42d14cfbef9d859a2
remote:          Building wheel for dash-html-components (setup.py): started
remote:          Building wheel for dash-html-components (setup.py): finished with status 'done'
remote:          Created wheel for dash-html-components: filename=dash_html_components-1.1.1-py3-none-a
ny.whl size=427894 sha256=3fdaff4591dcc615227f0dcd15a3fce058774bec0cc395406d0f11677429f099
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-szw5gfg5/wheels/ff/d9/16/e059d112e0d37
928fda032fd33eb0fb8507a584bf903c8ee20
remote:          Building wheel for dash-renderer (setup.py): started
remote:          Building wheel for dash-renderer (setup.py): finished with status 'done'
remote:          Created wheel for dash-renderer: filename=dash_renderer-1.8.0-py3-none-any.whl size=95
9342 sha256=5b58a35a8e54d700c94ede8ec5de7dbf56932c10746d19c05b805a452f22eb4c
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-szw5gfg5/wheels/7a/b2/29/6f1cb823fe858
b71325e5dda9399a33cf287327d97c8e3acde
remote:          Building wheel for dash-table (setup.py): started
remote:          Building wheel for dash-table (setup.py): finished with status 'done'
remote:          Created wheel for dash-table: filename=dash_table-4.10.1-py3-none-any.whl size=1824996
 sha256=e0d276a733036bfb4837887938adec2b9dad0cc93a8cff7c3fabce773b105800
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-szw5gfg5/wheels/41/db/98/ca192dd4b866c
fcf73d981eb61590ee0aed42c976018a6d722
remote:          Building wheel for future (setup.py): started
remote:          Building wheel for future (setup.py): finished with status 'done'
remote:          Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491058 sha256=f
66e820bba80ff99085b22cdb54cc861f76ca15c37cade7ba906ac736dc6685b
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-szw5gfg5/wheels/6e/9c/ed/4499c9865ac10
02697793e0ae05ba6be33553d098f3347fb94
remote:          Building wheel for pyodbc (setup.py): started
remote:          Building wheel for pyodbc (setup.py): finished with status 'error'
remote:          ERROR: Command errored out with exit status 1:
remote:           command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.
argv[0] = '"'"'/tmp/pip-install-exicu1kd/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-exicu1kd/
pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\
n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-
wheel-fgj7kkuy
remote:               cwd: /tmp/pip-install-exicu1kd/pyodbc/
remote:          Complete output (14 lines):
remote:          running bdist_wheel
remote:          running build
remote:          running build_ext
remote:          building 'pyodbc' extension
remote:          creating build
remote:          creating build/temp.linux-x86_64-3.6
remote:          creating build/temp.linux-x86_64-3.6/src
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DP
YODBC_VERSION=4.0.30 -I/app/.heroku/python/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x86
_64-3.6/src/buffer.o -Wno-write-strings
remote:          In file included from src/buffer.cpp:12:0:
remote:          src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
remote:           #include <sql.h>
remote:                    ^~~~~~~
remote:          compilation terminated.
remote:          error: command 'gcc' failed with exit status 1
remote:          ----------------------------------------
remote:          ERROR: Failed building wheel for pyodbc
remote:          Running setup.py clean for pyodbc
remote:          Building wheel for retrying (setup.py): started
remote:          Building wheel for retrying (setup.py): finished with status 'done'
remote:          Created wheel for retrying: filename=retrying-1.3.3-py3-none-any.whl size=11430 sha256
=4df872e2273b09ccddb59020ef1ce53e6a7624301d8e283fe5df99ce48cf23de
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-szw5gfg5/wheels/ac/cb/8a/b27bf6323e2f4
c462dcbf77d70b7c5e7868a7fbe12871770cf
remote:        Successfully built dash dash-core-components dash-html-components dash-renderer dash-tab
le future retrying
remote:        Failed to build pyodbc
remote:        Installing collected packages: Brotli, click, Werkzeug, itsdangerous, MarkupSafe, Jinja2
, Flask, Flask-Compress, six, retrying, plotly, dash-renderer, dash-core-components, dash-html-componen
ts, dash-table, future, dash, gunicorn, numpy, python-dateutil, pytz, pandas, pyodbc
remote:            Running setup.py install for pyodbc: started
remote:            Running setup.py install for pyodbc: finished with status 'error'
remote:            ERROR: Command errored out with exit status 1:
remote:             command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sy
s.argv[0] = '"'"'/tmp/pip-install-exicu1kd/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-exicu1k
d/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-ri_i42ot/install-record.txt --single-version-externally-managed --compile --install-headers
/app/.heroku/python/include/python3.6m/pyodbc
remote:                 cwd: /tmp/pip-install-exicu1kd/pyodbc/
remote:            Complete output (14 lines):
remote:            running install
remote:            running build
remote:            running build_ext
remote:            building 'pyodbc' extension
remote:            creating build
remote:            creating build/temp.linux-x86_64-3.6
remote:            creating build/temp.linux-x86_64-3.6/src
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -
DPYODBC_VERSION=4.0.30 -I/app/.heroku/python/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x
86_64-3.6/src/buffer.o -Wno-write-strings
remote:            In file included from src/buffer.cpp:12:0:
remote:            src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
remote:             #include <sql.h>
remote:                      ^~~~~~~
remote:            compilation terminated.
remote:            error: command 'gcc' failed with exit status 1
remote:            ----------------------------------------
remote:        ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'imp
ort sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-exicu1kd/pyodbc/setup.py'"'"'; __fil
e__='"'"'/tmp/pip-install-exicu1kd/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__fil
e__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'ex
ec'"'"'))' install --record /tmp/pip-record-ri_i42ot/install-record.txt --single-version-externally-man
aged --compile --install-headers /app/.heroku/python/include/python3.6m/pyodbc Check the logs for full
command output.
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed

heroku 上似乎没有 odbc 驱动程序。经过几天尝试现有主题的许多解决方案后,我发现解决该问题的最佳方法是在 heroku 上使用buildpacks。我发现了这个:https://elements.heroku.com/buildpacks/statestitle/python-pyodbc-buildpack

要求

所以我在我的根文件夹中添加Aptfile 的内容:

unixodbc
unixodbc-dev
python-pyodbc
libsqliteodbc

我在终端运行:

heroku buildpacks:add --index 1 https://github.co
m/heroku/heroku-buildpack-apt.git

heroku buildpacks:add --index 1 https://github.co
m/heroku/heroku-buildpack-python.git

heroku buildpacks:add --index 1 https://github.co
m/matt-bertoncello/python-pyodbc-buildpack.git

我得到信息:

Buildpack added. Next release on newcharts4 will use:
  1. https://github.com/matt-bertoncello/python-pyodbc-buildpack.git
  2. https://github.com/heroku/heroku-buildpack-python.git
  3. https://github.com/heroku/heroku-buildpack-apt.git
Run git push heroku main to create a new release using these buildpacks.

所以我跑了:

git checkout -b main
git push heroku main

我得到错误:

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 295 bytes | 295.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> odbc app detected
remote: -----> Starting adding ODBC Driver 17 for SQL Server
remote: -----> copied libmsodbcsql-17.5.so.2.1
remote: -----> copied msodbcsqlr17.rll
remote: -----> copied odbcinst.ini
remote: -----> copied profile.d
remote: -----> Finished adding ODBC Driver 17 for SQL Server
remote: -----> Python app detected
remote: -----> Requirements file has been changed, clearing cached dependencies
remote: -----> Installing python-3.6.12
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:        Collecting Brotli==1.0.9
remote:          Downloading Brotli-1.0.9-cp36-cp36m-manylinux1_x86_64.whl (357 kB)
remote:        Collecting click==7.1.2
remote:          Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
remote:        Collecting dash==1.16.0
remote:          Downloading dash-1.16.0.tar.gz (72 kB)
remote:        Collecting dash-core-components==1.12.0
remote:          Downloading dash_core_components-1.12.0.tar.gz (3.4 MB)
remote:        Collecting dash-html-components==1.1.1
remote:          Downloading dash_html_components-1.1.1.tar.gz (188 kB)
remote:        Collecting dash-renderer==1.8.0
remote:          Downloading dash_renderer-1.8.0.tar.gz (950 kB)
remote:        Collecting dash-table==4.10.1
remote:          Downloading dash_table-4.10.1.tar.gz (1.8 MB)
remote:        Collecting Flask==1.1.2
remote:          Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
remote:        Collecting Flask-Compress==1.8.0
remote:          Downloading Flask_Compress-1.8.0-py3-none-any.whl (7.2 kB)
remote:        Collecting future==0.18.2
remote:          Downloading future-0.18.2.tar.gz (829 kB)
remote:        Collecting gunicorn==20.0.4
remote:          Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
remote:        Collecting itsdangerous==1.1.0
remote:          Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
remote:        Collecting Jinja2==2.11.2
remote:          Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
remote:        Collecting MarkupSafe==1.1.1
remote:          Downloading MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (27 kB)
remote:        Collecting numpy==1.19.1
remote:          Downloading numpy-1.19.1-cp36-cp36m-manylinux2010_x86_64.whl (14.5 MB)
remote:        Collecting pandas==1.0.0
remote:          Downloading pandas-1.0.0-cp36-cp36m-manylinux1_x86_64.whl (10.1 MB)
remote:        Collecting plotly==4.10.0
remote:          Downloading plotly-4.10.0-py2.py3-none-any.whl (13.0 MB)
remote:        Collecting pyodbc==4.0.30
remote:          Downloading pyodbc-4.0.30.tar.gz (266 kB)
remote:        Collecting python-dateutil==2.8.1
remote:          Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
remote:        Collecting pytz==2020.5
remote:          Downloading pytz-2020.5-py2.py3-none-any.whl (510 kB)
remote:        Collecting retrying==1.3.3
remote:          Downloading retrying-1.3.3.tar.gz (10 kB)
remote:        Collecting six==1.15.0
remote:          Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
remote:        Collecting Werkzeug==1.0.1
remote:          Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
remote:        Building wheels for collected packages: dash, dash-core-components, dash-html-components
, dash-renderer, dash-table, future, pyodbc, retrying
remote:          Building wheel for dash (setup.py): started
remote:          Building wheel for dash (setup.py): finished with status 'done'
remote:          Created wheel for dash: filename=dash-1.16.0-py3-none-any.whl size=82326 sha256=6077aa
a19fc50c1ead9321ac52092c2292cd3c08724cd91f6b27393fb649a86e
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-wcomcto1/wheels/27/eb/db/c0b2c44cb5418
e31c872c435cb39123654229ce425e10282b0
remote:          Building wheel for dash-core-components (setup.py): started
remote:          Building wheel for dash-core-components (setup.py): finished with status 'done'
remote:          Created wheel for dash-core-components: filename=dash_core_components-1.12.0-py3-none-
any.whl size=3478746 sha256=2dfd9f6b628a20028ecb6d1848c5fdf27b32990a515566159f4102be84744e1a
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-wcomcto1/wheels/18/71/84/1d7c538fb95fe
c74bc2f854a38e96e0ec42d14cfbef9d859a2
remote:          Building wheel for dash-html-components (setup.py): started
remote:          Building wheel for dash-html-components (setup.py): finished with status 'done'
remote:          Created wheel for dash-html-components: filename=dash_html_components-1.1.1-py3-none-a
ny.whl size=427894 sha256=b5be3fb70aa0f2b7a27c9daf31f2de35f0ababfc8a75e0e12d822bd5f25e3b04
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-wcomcto1/wheels/ff/d9/16/e059d112e0d37
928fda032fd33eb0fb8507a584bf903c8ee20
remote:          Building wheel for dash-renderer (setup.py): started
remote:          Building wheel for dash-renderer (setup.py): finished with status 'done'
remote:          Created wheel for dash-renderer: filename=dash_renderer-1.8.0-py3-none-any.whl size=95
9342 sha256=51c4df2751ac2f73605d386c047c5f70f92837e46973187ebb3723ec173495af
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-wcomcto1/wheels/7a/b2/29/6f1cb823fe858
b71325e5dda9399a33cf287327d97c8e3acde
remote:          Building wheel for dash-table (setup.py): started
remote:          Building wheel for dash-table (setup.py): finished with status 'done'
remote:          Created wheel for dash-table: filename=dash_table-4.10.1-py3-none-any.whl size=1824996
 sha256=f727e9ae0666b02502c2548b5d4d45d5734c3ead1be73c46372b5abc5a8cc328
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-wcomcto1/wheels/41/db/98/ca192dd4b866c
fcf73d981eb61590ee0aed42c976018a6d722
remote:          Building wheel for future (setup.py): started
remote:          Building wheel for future (setup.py): finished with status 'done'
remote:          Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491058 sha256=e
8fac62f340e01bf5eae738040d0f1c1504167544f561c1209a278ad688bf693
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-wcomcto1/wheels/6e/9c/ed/4499c9865ac10
02697793e0ae05ba6be33553d098f3347fb94
remote:          Building wheel for pyodbc (setup.py): started
remote:          Building wheel for pyodbc (setup.py): finished with status 'error'
remote:          ERROR: Command errored out with exit status 1:
remote:           command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.
argv[0] = '"'"'/tmp/pip-install-_mzfztmy/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_mzfztmy/
pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\
n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-
wheel-hriunqel
remote:               cwd: /tmp/pip-install-_mzfztmy/pyodbc/
remote:          Complete output (14 lines):
remote:          running bdist_wheel
remote:          running build
remote:          running build_ext
remote:          building 'pyodbc' extension
remote:          creating build
remote:          creating build/temp.linux-x86_64-3.6
remote:          creating build/temp.linux-x86_64-3.6/src
remote:          gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DP
YODBC_VERSION=4.0.30 -I/app/.heroku/python/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x86
_64-3.6/src/buffer.o -Wno-write-strings
remote:          In file included from src/buffer.cpp:12:0:
remote:          src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
remote:           #include <sql.h>
remote:                    ^~~~~~~
remote:          compilation terminated.
remote:          error: command 'gcc' failed with exit status 1
remote:          ----------------------------------------
remote:          ERROR: Failed building wheel for pyodbc
remote:          Running setup.py clean for pyodbc
remote:          Building wheel for retrying (setup.py): started
remote:          Building wheel for retrying (setup.py): finished with status 'done'
remote:          Created wheel for retrying: filename=retrying-1.3.3-py3-none-any.whl size=11430 sha256
=906eb9e8697f8519879b829838be9df599f431a711ae7e6387e43f666ee29419
remote:          Stored in directory: /tmp/pip-ephem-wheel-cache-wcomcto1/wheels/ac/cb/8a/b27bf6323e2f4
c462dcbf77d70b7c5e7868a7fbe12871770cf
remote:        Successfully built dash dash-core-components dash-html-components dash-renderer dash-tab
le future retrying
remote:        Failed to build pyodbc
remote:        Installing collected packages: Brotli, click, itsdangerous, MarkupSafe, Jinja2, Werkzeug
, Flask, Flask-Compress, six, retrying, plotly, dash-renderer, dash-core-components, dash-html-componen
ts, dash-table, future, dash, gunicorn, numpy, pytz, python-dateutil, pandas, pyodbc
remote:            Running setup.py install for pyodbc: started
remote:            Running setup.py install for pyodbc: finished with status 'error'
remote:            ERROR: Command errored out with exit status 1:
remote:             command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sy
s.argv[0] = '"'"'/tmp/pip-install-_mzfztmy/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_mzfztm
y/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-gc0x1td4/install-record.txt --single-version-externally-managed --compile --install-headers
/app/.heroku/python/include/python3.6m/pyodbc
remote:                 cwd: /tmp/pip-install-_mzfztmy/pyodbc/
remote:            Complete output (14 lines):
remote:            running install
remote:            running build
remote:            running build_ext
remote:            building 'pyodbc' extension
remote:            creating build
remote:            creating build/temp.linux-x86_64-3.6
remote:            creating build/temp.linux-x86_64-3.6/src
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -
DPYODBC_VERSION=4.0.30 -I/app/.heroku/python/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x
86_64-3.6/src/buffer.o -Wno-write-strings
remote:            In file included from src/buffer.cpp:12:0:
remote:            src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
remote:             #include <sql.h>
remote:                      ^~~~~~~
remote:            compilation terminated.
remote:            error: command 'gcc' failed with exit status 1
remote:            ----------------------------------------
remote:        ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'imp
ort sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_mzfztmy/pyodbc/setup.py'"'"'; __fil
e__='"'"'/tmp/pip-install-_mzfztmy/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__fil
e__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'ex
ec'"'"'))' install --record /tmp/pip-record-gc0x1td4/install-record.txt --single-version-externally-man
aged --compile --install-headers /app/.heroku/python/include/python3.6m/pyodbc Check the logs for full
command output.
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: c46e5131dd80bb9b3a7fc4e84
45239825f56f035
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version c46e5131dd80b
b9b3a7fc4e8445239825f56f035
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a differ
ent branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:

我是否正确使用了这个 buildpacks 和 Aptfile? Aptfile 的确切名称应该是什么?

【问题讨论】:

    标签: python heroku pyodbc


    【解决方案1】:

    作为 buildpack 的创建者 - 看起来您正在以相反的顺序运行 buildpack。预期的 buildpack 顺序是:

      1. https://github.com/heroku/heroku-buildpack-apt.git
      2. https://github.com/heroku/heroku-buildpack-python.git
      3. https://github.com/matt-bertoncello/python-pyodbc-buildpack.git
    

    您可以按此顺序尝试并评论您的结果吗?

    编辑:同时从 aptfile 中删除 python-pyodbc

    【讨论】:

    • 我有同样的错误我试过你的序列它没有工作给出同样的错误' E: Unable to locate package python-pyodbc remote: ! Push 被拒绝,无法编译 Apt 应用程序。远程:远程:!推送失败的远程:验证部署...远程:远程:!推送被拒绝到 fyp-sql-api。
    • @MoonLight 我错过了不正确的 aptfile。我将更新我的答案,建议从 aptfile 中删除 python-pyodbc
    • 好的,谢谢,我会检查并告诉你
    【解决方案2】:

    您应该在终端中按以下顺序运行: heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt.git

    heroku buildpacks:add --index 2 https://github.com/heroku/heroku-buildpack-python.git

    heroku buildpacks:add --index 3 https://github.com/matt-bertoncello/python-pyodbc-buildpack.git

    【讨论】:

    猜你喜欢
    • 2018-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-15
    • 2018-11-23
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    相关资源
    最近更新 更多