Error installing pymssql on Mac OS X Lion

大憨熊 提交于 2019-12-03 08:55:30

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

Drewes

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

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

brew install freetds
sudo pip install pymssql
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!