python 安裝mssql擴展

  linux下連接SQL SERVER 可是一件非常痛苦的事情,python下有pymssql擴展庫去連接,但是安裝確實比較麻煩和痛苦

開始很自然的想到
easy_install pymssql
出現
Searching for pymssql
Reading https://pypi.python.org/simple/pymssql/
Reading http://code.google.com/p/pymssql/
Reading http://code.google.com/p/pymssql/downloads/list
Reading http://pymssql.sourceforge.net
Download error on http://pymssql.sourceforge.net: timed out -- Some packages may not be found!
Reading http://sourceforge.net/project/showfiles.php?group_id=40059&package_id=32202
Best match: pymssql 2.0.0b1-dev-20130403
Downloading http://pymssql.googlecode.com/files/pymssql-2.0.0b1-dev-20130403.tar.gz
Processing pymssql-2.0.0b1-dev-20130403.tar.gz
Writing /tmp/easy_install-Q0iuH6/pymssql-2.0.0b1-dev-20130403/setup.cfg
Running pymssql-2.0.0b1-dev-20130403/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Q0iuH6/pymssql-2.0.0b1-dev-20130403/egg-dist-tmp-iZ2UMu
creating tmp
creating tmp/easy_install-Q0iuH6
creating tmp/easy_install-Q0iuH6/pymssql-2.0.0b1-dev-20130403
creating tmp/easy_install-Q0iuH6/pymssql-2.0.0b1-dev-20130403/temp
cc -c /tmp/easy_install-Q0iuH6/pymssql-2.0.0b1-dev-20130403/temp/clock_gettime8KzG4j.c -o tmp/easy_install-Q0iuH6/pymssql-2.0.0b1-dev-20130403/temp/clock_gettime8KzG4j.o
cc tmp/easy_install-Q0iuH6/pymssql-2.0.0b1-dev-20130403/temp/clock_gettime8KzG4j.o -lrt -o a.out
warning: no files found matching 'win32/freetds.zip'
/usr/bin/ld: cannot find -lct
collect2: ld returned 1 exit status
error: Setup script exited with error: command 'gcc' failed with exit status 1
很自然以爲系統沒有安裝python-devel
yum install python-devel
顯示已經安裝
然後從pypi下載軟件包安裝
python setup.py build
running build
running build_ext
skipping '_mssql.c' Cython extension (up-to-date)
building '_mssql' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/root/pymssql-2.0.0b1-dev-20130403/freetds/nix_64/include -I/usr/include/python2.6 -c _mssql.c -o build/temp.linux-x86_64-2.6/_mssql.o -Wno-parentheses-equality -DMSDBLIB
gcc -pthread -shared build/temp.linux-x86_64-2.6/_mssql.o -L/root/pymssql-2.0.0b1-dev-20130403/freetds/nix_64/lib -L/usr/lib64 -lsybdb -lct -lrt -lpython2.6 -o build/lib.linux-x86_64-2.6/_mssql.so
/usr/bin/ld: cannot find -lct
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
還是gcc 不過上面說skipping '_mssql.c' Cython extension (up-to-date)
然後查看build/temp.linux-x86_64-2.6/目錄空空
說明庫沒有編譯上
google了一下發現是freetds的問題
下載安裝
過程如下:
tar xvf freetds-stable.tgz
cd freetds-0.91/
./configure  --with-tdsver=8.0 --enable-msdblib
make && make install
解決問題


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章