小编典典

在OSX 10.9(Mavericks)上安装pyodbc失败

python

跑步时pip install pyodbc,我得到

In file included from .../build/pyodbc/src/buffer.cpp:12:
    .../build/pyodbc/src/pyodbc.h:52:10: fatal error: 'sql.h' file not found
    #include <sql.h>
             ^
    1 error generated.
    error: command 'cc' failed with exit status 1

看来Mavericks在/ usr / include下没有sql.h

是否有人设法安装pyodbc?有已知的解决方法吗?


阅读 234

收藏
2021-01-20

共1个答案

小编典典

如您所见,OSX Mavericks删除了PyODBC编译所需的sql标头。按照以下步骤操作,可以安装PyODBC:

  1. 确保已安装iODBC库(http://www.iodbc.org/
  2. 下载并解压缩iODBC源
  3. pip install --no-install pyodbc
  4. cd [VIRTUAL_ENV]/build/pyodbc
  5. python setup.py build_ext --include-dirs=[LIBIODBC_SOURCES]/include/
  6. 运行pip install --no-download pyodbc
    Installing collected packages: pyodbc
    

    Running setup.py install for pyodbc

    warning: no files found matching 'tests/*'
    

    Successfully installed pyodbc
    Cleaning up…

我也可以将文件复制[libiodbc_sources]/include/到我的文件中,/usr/include然后运行pip install pyodbc,但是我不想手动将文件添加到系统文件夹。

2021-01-20