2012-02-06 132 views
3

我安裝了XCode並且還安裝了FreeTDS。我試圖連接到我的SQL Server,它的工作原理非常完美。在Mac OS X Lion上安裝pymssql時出錯

現在我已經制定蟒蛇與此SQL Server和我正嘗試安裝pymsql工作的aplication,但是當我launche sudo的蟒蛇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 

任何幫助或線索?

+0

你創建的文件夾:「/ sw/lib「,」/ opt/local/lib「...? – CarlJ 2012-02-06 14:40:57

+0

不......我必須? – 2012-02-06 14:42:28

回答

11

不幸的是,pymssql的setup.py(從版本pymssql-2.0.0b1-dev-20111019開始)需要一些幫助才能在OSX Lion上正常工作。當前的setup.py嘗試編譯/鏈接一些預先構建的Linux FreeTDS庫,並嘗試鏈接到libx,OSX上不存在該庫。此外,它僅顯式查找來自Fink或MacPorts的FreeTDS庫,因此如果您在非標準位置安裝了Homebrew(如果使用if)或FreeTDS本身,則可能無法通過編譯器/鏈接程序找到它。

我創建了一個修復版本的setup.py here。對於使用標準位置(/ usr/local/{lib,include})的FreeTDS的Homebrew版本,它對我來說足夠好,但是一如既往YMMV。如果您已將FreeTDS安裝在其他位置,則可能需要進一步調整setup.py。你通常可以忽略從鏈接失蹤,可能不是你的系統上存在的目錄的警告:

LD:警告:未找到選項目錄「-L在/ usr/local/lib目錄/ freetds的」

一其他說明:您可能已經爲單個架構構建了FreeTDS,可能是x86_64。默認情況下,pymssl將是一個多架構版本(假設您使用的是系統Python 2.7.1),所以即使修補了setup.py,您也會看到鏈接器警告,如:

ld:warning:忽略文件/usr/local/lib/libsybdb.dylib,文件是爲不支持的文件格式構建的,而不是被鏈接的體系結構(i386)

該警告只是表示FreeTDS庫只有單個體繫結構版本才能鏈接。您可以通過使用ARCHFLAGS來構建x86_64構建來避免警告:

ARCHFLAGS =「 - arch x86_64」python setup。PY安裝

+0

+1良好的解釋和鏈接到setup.py幫助讓事情正常工作。 – dlamotte 2012-05-07 20:32:43

+0

謝謝!完全救了我。 – 2012-09-25 07:06:48

2

只是櫃面任何人在讀這以下爲我工作:

brew install freetds 
sudo pip install pymssql