Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

python - Installing pyodbc fails on OSX 10.9 (Mavericks)

When running pip install pyodbc, I get

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

It seems that Mavericks has no sql.h under /usr/include

Did anyone manage to install pyodbc? Is there a known workaround?

question from:https://stackoverflow.com/questions/20074620/installing-pyodbc-fails-on-osx-10-9-mavericks

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As you noticed OSX Mavericks dropped sql headers that are required for PyODBC compilation. Following these steps allowed me to install PyODBC:

  1. Make sure you have iODBC library installed (http://www.iodbc.org/)
  2. Download and extract iODBC sources
  3. Run pip install --no-install pyodbc
  4. cd [VIRTUAL_ENV]/build/pyodbc
  5. Run python setup.py build_ext --include-dirs=[LIBIODBC_SOURCES]/include/
  6. Run 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...
    

I could as well copy the files under [libiodbc_sources]/include/ to my /usr/include and just run pip install pyodbc, but I didn't want to add files manually to system folders.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...