我安装了 XCode 和 FreeTDS。我尝试连接到我的 SQL Server,它工作得很好。
现在我必须在 python 上开发一个与此 SQL Server 配合使用的应用程序,并且我正在尝试安装 pymysql,但是当我启动 sudo python setup.py 命令时出现此错误:
==> sudo python setup.py install
running install
running bdist_egg
running egg_info
writing pymssql.egg-info/PKG-INFO
writing top-level names to pymssql.egg-info/top_level.txt
writing dependency_links to pymssql.egg-info/dependency_links.txt
reading manifest file 'pymssql.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pymssql.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-intel/egg
running install_lib
running build_ext
skipping '_mssql.c' Cython extension (up-to-date)
building '_mssql' extension
llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/sw/include -Ifreetds/nix_64/include -I/opt/local/include -I/opt/local/include/freetds -I/opt/local/freetds/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mssql.c -o build/temp.macosx-10.7-intel-2.7/_mssql.o -DMSDBLIB
_mssql.c: In function ‘__pyx_f_6_mssql_15MSSQLConnection_convert_python_value’:
_mssql.c:7322: warning: implicit conversion shortens 64-bit value into a 32-bit value
_mssql.c: In function ‘__pyx_f_6_mssql_15MSSQLConnection_get_result’:
_mssql.c:9554: warning: implicit conversion shortens 64-bit value into a 32-bit value
_mssql.c:9566: warning: implicit conversion shortens 64-bit value into a 32-bit value
_mssql.c: In function ‘__pyx_pf_6_mssql_20MSSQLStoredProcedure_2bind’:
_mssql.c:11146: warning: implicit conversion shortens 64-bit value into a 32-bit value
llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/_mssql.o -L/sw/lib -Lfreetds/nix_64/lib -L/opt/local/lib -L/opt/local/lib/freetds -L/opt/local/freetds/lib -lsybdb -lrt -o build/lib.macosx-10.7-intel-2.7/_mssql.so
ld: warning: directory not found for option '-L/sw/lib'
ld: warning: directory not found for option '-L/opt/local/lib'
ld: warning: directory not found for option '-L/opt/local/lib/freetds'
ld: warning: directory not found for option '-L/opt/local/freetds/lib'
ld: library not found for -lrt
collect2: ld returned 1 exit status
ld: warning: directory not found for option '-L/sw/lib'
ld: warning: directory not found for option '-L/opt/local/lib'
ld: warning: directory not found for option '-L/opt/local/lib/freetds'
ld: warning: directory not found for option '-L/opt/local/freetds/lib'
ld: library not found for -lrt
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//cc6eQsIN.out (No such file or directory)
error: command 'llvm-gcc-4.2' failed with exit status 1
有什么帮助或线索吗?
不幸的是,pymssql 的 setup.py(从版本 pymssql-2.0.0b1-dev-20111019 开始)需要一些帮助才能在 OSX Lion 上正常工作。当前的 setup.py 尝试针对一些预构建的 Linux FreeTDS 库进行编译/链接,并且还尝试针对 OSX 上不存在的 librt 进行链接。此外,它仅显式查找来自 Fink 或 MacPorts 的 FreeTDS 库,因此,如果您在非标准位置安装了 Homebrew(如果使用 if)或 FreeTDS 本身,则编译器/链接器可能无法找到它。
我创建了 setup.py 的修复版本here http://code.google.com/r/dinkypumpkin-pymssql/source/browse/setup.py。它对我来说使用标准位置(/usr/local/{lib, include})的 FreeTDS Homebrew 版本运行得很好,但一如既往的 YMMV。如果您已将 FreeTDS 安装在其他位置,则可能需要进一步调整 setup.py。您通常可以忽略链接器发出的有关系统上可能不存在的丢失目录的警告:
ld:警告:找不到选项“-L/usr/local/lib/freetds”的目录
另请注意:您可能会为单一架构(可能是 x86_64)构建 FreeTDS。默认情况下,pymssl 将是多架构构建(假设您使用的是 Python 2.7.1 系统),因此即使使用修补后的 setup.py,您也会看到类似以下内容的链接器警告:
ld:警告:忽略文件 /usr/local/lib/libsybdb.dylib,该文件是为不受支持的文件格式构建的,该格式不是正在链接的体系结构(i386)
该警告仅表明 FreeTDS 库只有单一架构版本可供链接。您可以使用 ARCHFLAGS 进行仅限 x86_64 的构建来避免出现警告:
ARCHFLAGS="-arch x86_64" python setup.py install
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)