Error installing pymssql on Mac OS X Lion

后端 未结 3 974
死守一世寂寞
死守一世寂寞 2021-02-11 01:30

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:44

    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

提交回复
热议问题