Error installing pymssql on Mac OS X Lion

后端 未结 3 1457
南笙
南笙 2021-02-11 01:26

I have XCode installed and also FreeTDS. I tried to connect to my SQL Server and it works perfect.

Now I have to develop an aplication on python that works with this SQL

相关标签:
3条回答
  • 2021-02-11 01:51

    Just incase anyone is reading this the following worked for me:

    brew install freetds
    sudo pip install pymssql
    
    0 讨论(0)
  • 2021-02-11 01:58

    Or, try this fork, it installs without issues:

    https://github.com/blackbass1988/pymssql-macos-lion

    To install on OS X Mavericks, you need

    OS X Command Line Tools

    FreeTDS

    brew install freetds
    

    Cython

    pip install cython
    

    and then finally you can install the pymssql-macoslion

    pip install git+git://github.com/blackbass1988/pymssql-macos-lion.git@master
    
    0 讨论(0)
  • 2021-02-11 01:59

    Unfortunately, pymssql's setup.py (as of version pymssql-2.0.0b1-dev-20111019) needs a bit of help to work properly on OSX Lion. The current setup.py tries to compile/link against some pre-built Linux FreeTDS libraries, and also tries to link against librt, which doesn't exist on OSX. Additionally, it only explicitly looks for FreeTDS libraries from Fink or MacPorts, so if you've installed Homebrew (if you use if) or FreeTDS itself in a non-standard location, it may not be located by compiler/linker.

    I created a repaired version of setup.py here. It worked well enough for me with the Homebrew build of FreeTDS using the standard locations (/usr/local/{lib, include}), but as always YMMV. You may need to adjust setup.py further if you've installed FreeTDS in a different location. You can generally ignore the warnings from the linker about missing directories that may not exist on your system:

    ld: warning: directory not found for option '-L/usr/local/lib/freetds'

    One other note: You will probably have built FreeTDS for a single architecture, likely x86_64. By default, pymssl will be a multi-architecture build (assuming you're using the system Python 2.7.1), so even with a patched setup.py you will see a linker warning something like:

    ld: warning: ignoring file /usr/local/lib/libsybdb.dylib, file was built for unsupported file format which is not the architecture being linked (i386)

    That warning just indicates that the FreeTDS libraries only have single architecture version to link against. You can avoid the warning by using ARCHFLAGS to make a x86_64-only build:

    ARCHFLAGS="-arch x86_64" python setup.py install

    0 讨论(0)
提交回复
热议问题