2013-06-28 99 views
47

我想在pbuntu上安裝pymssql,使用pip在Ubuntu 12.04上。這是我得到的錯誤。任何幫助將不勝感激,因爲我完全失去了!試圖在Ubuntu 12.04上使用pip安裝pymssql

試着用搜索引擎這個可惜不得要領......

Downloading pymssql-2.0.0b1-dev-20130403.tar.gz (2.8Mb): 2.8Mb downloaded 
    Running setup.py egg_info for package pymssql 
    warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests' 
    warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests' 
    warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests' 
    warning: no files found matching '*.pxd' under directory 'Cython/Utility' 
    Compiling module Cython.Plex.Scanners ... 
    Compiling module Cython.Plex.Actions ... 
    Compiling module Cython.Compiler.Lexicon ... 
    Compiling module Cython.Compiler.Scanning ... 
    Compiling module Cython.Compiler.Parsing ... 
    Compiling module Cython.Compiler.Visitor ... 
    Compiling module Cython.Compiler.FlowControl ... 
    Compiling module Cython.Compiler.Code ... 
    Compiling module Cython.Runtime.refnanny ... 

    Installed /home/radek/build/pymssql/Cython-0.19.1-py2.7-linux-x86_64.egg 
    cc -c /tmp/clock_gettimeh7sDgX.c -o tmp/clock_gettimeh7sDgX.o 
    cc tmp/clock_gettimeh7sDgX.o -lrt -o a.out 

    warning: no files found matching 'win32/freetds.zip' 
Installing collected packages: pymssql 
    Running setup.py install for pymssql 
    skipping '_mssql.c' Cython extension (up-to-date) 
    building '_mssql' extension 
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/radek/build/pymssql/freetds/nix_64/include -I/usr/include/python2.7 -c _mssql.c -o build/temp.linux-x86_64-2.7/_mssql.o -Wno-parentheses-equality -DMSDBLIB 
    gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_mssql.o -L/home/radek/build/pymssql/freetds/nix_64/lib -lsybdb -lct -lrt -o build/lib.linux-x86_64-2.7/_mssql.so 
    /usr/bin/ld: cannot find -lct 
    collect2: ld returned 1 exit status 
    error: command 'gcc' failed with exit status 1 
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/radek/build/pymssql/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-Et_P1_-record/install-record.txt: 
    running install 

running build 

running build_ext 

skipping '_mssql.c' Cython extension (up-to-date) 

building '_mssql' extension 

creating build 

creating build/temp.linux-x86_64-2.7 

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/home/radek/build/pymssql/freetds/nix_64/include -I/usr/include/python2.7 -c _mssql.c -o build/temp.linux-x86_64-2.7/_mssql.o -Wno-parentheses-equality -DMSDBLIB 

creating build/lib.linux-x86_64-2.7 

gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_mssql.o -L/home/radek/build/pymssql/freetds/nix_64/lib -lsybdb -lct -lrt -o build/lib.linux-x86_64-2.7/_mssql.so 

/usr/bin/ld: cannot find -lct 

collect2: ld returned 1 exit status 

error: command 'gcc' failed with exit status 1 

---------------------------------------- 
Command /usr/bin/python -c "import setuptools;__file__='/home/radek/build/pymssql/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-Et_P1_-record/install-record.txt failed with error code 1 
+5

正是如此,這是搜索:Ubuntu的14.04將引發「mssql.c:346:22:致命錯誤:sqlfront.h:沒有這樣的文件或目錄「。按照下面的答案安裝freetds-dev修復了這個問題。 – SaeX

回答

123

確保你已經安裝了python-dev包(需要編譯本地綁定包(感謝@ravihemnani)。

然後你需要嘗試使用PIP安裝pymssql之前安裝freetds的開發包(freetds-dev):

$ sudo apt-get install freetds-dev 

,然後在你的的virtualenv或任何你想要安裝:

$ pip install pymssql 
+0

如果pip不起作用:sudo apt-get install python-pip將安裝pip –

+0

sudo apt-get install -y freetds-dev解​​決了我的問題。謝謝。 –

+0

在debian和apt-get安裝中出現同樣的問題freetds-dev也解決了我的問題! – alireza

11
從freetds的-dev的

除此之外,你需要安裝python-DEV以及隨之而來。

sudo apt-get install python-dev 

否則,您將再次面臨一些錯誤。

+0

這個評論是很重要的,以使接受的評論成功! (至少在14.04LTS)謝謝,Ravihemnani –

+1

歡迎尼爾:D – ravihemnani

3

對於那些在openSUSE(以及相關的操作系統):

zypper in freetds-devel 
pip install pymssql