trying to install pymssql on ubuntu 12.04 using pip

37,310

Solution 1

Make sure you have the python-dev package installed (needed to compile packages with native bindings (thanks to @ravihemnani).

Then you'll need to install the FreeTDS development package (freetds-dev) before trying to install pymssql with pip:

$ sudo apt-get install freetds-dev

and then, in your virtualenv or wherever you wish to install it:

$ pip install pymssql

Solution 2

Apart from freetds-dev, you need to install python-dev as well as follow.

sudo apt-get install python-dev

Or else, you will again face some error.

Solution 3

For those on OpenSuse (and related OSes):

zypper in freetds-devel
pip install pymssql

Solution 4

On Mac

brew install [email protected]
brew link --force [email protected]
pip install pymssql
Share:
37,310
dreamwalker
Author by

dreamwalker

Updated on June 21, 2020

Comments

  • dreamwalker
    dreamwalker almost 4 years

    I am trying to install pymssql on ubuntu 12.04 using pip. This is the error I am getting. Any help would be greatly appreciated as I am completely lost!

    Tried googling this but unfortunately to no avail...

      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
    
    • SaeX
      SaeX over 9 years
      Just so this is searchable: Ubuntu 14.04 will throw "mssql.c:346:22: fatal error: sqlfront.h: No such file or directory". Installing freetds-dev fixes the issue as per the answer below.
  • David Aleu
    David Aleu over 10 years
    if pip doesn't work: sudo apt-get install python-pip will install pip
  • Neal Magee
    Neal Magee about 8 years
    This comment is VITAL to make the accepted comment succeed! (At least in 14.04LTS) Thanks, Ravihemnani
  • Tony Vu
    Tony Vu about 8 years
    sudo apt-get install -y freetds-dev solves my issue. Thanks.
  • alireza
    alireza almost 8 years
    same issue in debian and apt-get install freetds-dev solved my problem too !
  • nima
    nima over 7 years
    I needed export C_INCLUDE_PATH=/usr/include too.
  • Alexander Taubenkorb
    Alexander Taubenkorb over 6 years
    This also worked on my Raspberry Pi, however I had to install pymssql as root with sudo pip3 install pymssql because I got a PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/_mssql.cpython-35m-a‌​rm-linux-gnueabihf.s‌​o'