pyodbc安装在heroku服务器错误命令" gcc"退出状态1失败 - Django项目

时间:2016-04-25 19:00:41

标签: django heroku pip pyodbc

我正在运行一个heroku应用程序,并使用pyODBC。

当我尝试在我的heroku服务器上安装pyodbc时出现此错误。

当我尝试将pyodbc放在requirements.txt文件中时,会发生同样的事情。

我根本不知道如何处理此错误,我似乎无法通过windows heroku toolbelt找到如何在heroku服务器上使用sudo apt-get等命令。

这是错误过程。

C:\Users\mads\businesszone>heroku run pip install pyodbc
Running pip install pyodbc on businesszone... up, run.9537
Collecting pyodbc
  Downloading pyodbc-3.0.10.tar.gz (68kB)
    100% |████████████████████████████████| 71kB 4.3MB/s
Installing collected packages: pyodbc
  Running setup.py install for pyodbc ... error
    Complete output from command /app/.heroku/python/bin/python -u -c "import se
tuptools, tokenize;__file__='/tmp/pip-build-jJIUQ3/pyodbc/setup.py';exec(compile
(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file_
_, 'exec'))" install --record /tmp/pip-J0_eAS-record/install-record.txt --single
-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'pyodbc' extension
    creating build
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/tmp
    creating build/temp.linux-x86_64-2.7/tmp/pip-build-jJIUQ3
    creating build/temp.linux-x86_64-2.7/tmp/pip-build-jJIUQ3/pyodbc
    creating build/temp.linux-x86_64-2.7/tmp/pip-build-jJIUQ3/pyodbc/src
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstr
ict-prototypes -fPIC -DPYODBC_VERSION=3.0.10 -DPYODBC_UNICODE_WIDTH=2 -I/Applica
tions/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacO
SX10.8.sdk/usr/include -I/app/.heroku/python/include/python2.7 -c /tmp/pip-build
-jJIUQ3/pyodbc/src/cnxninfo.cpp -o build/temp.linux-x86_64-2.7/tmp/pip-build-jJI
UQ3/pyodbc/src/cnxninfo.o -Wno-write-strings
    cc1plus: warning: command line option `-Wstrict-prototypes' is valid for C/O
bjC but not for C++ [enabled by default]
    In file included from /tmp/pip-build-jJIUQ3/pyodbc/src/cnxninfo.cpp:8:0:
    /tmp/pip-build-jJIUQ3/pyodbc/src/pyodbc.h:52:17: fatal error: sql.h: No such
 file or directory
     #include <sql.h>
                     ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__fil
e__='/tmp/pip-build-jJIUQ3/pyodbc/setup.py';exec(compile(getattr(tokenize, 'open
', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --r
ecord /tmp/pip-J0_eAS-record/install-record.txt --single-version-externally-mana
ged --compile" failed with error code 1 in /tmp/pip-build-jJIUQ3/pyodbc/

我还试图通过pip和旧谷歌代码项目中的zip来安装一些旧的pyodbc版本: https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pyodbc/pyodbc-3.0.7.zip



UPDATE ::您需要制作自己的heroku buildpack。见图。 enter image description here

help output on heroku server

1 个答案:

答案 0 :(得分:5)

您没有安装unixODBC dev软件包。我不确定如何在Heroku上安装,但这里有两个例子:

Ubuntu示例:

sudo apt-get install unixodbc unixodbc-dev

CentOS示例:

sudo yum install unixODBC-devel

您可能还想考虑安装virtualenv,而不是在系统范围内安装pyodbc