Search code examples
pythoncentospipfreetdspymssql

Python2.7 - pip install pymssql fails on CentOS 6.3


I am trying to install pymssql for Python on a CentOS machine however it keeps failing on me.

I have already installed the following:

freetds-devel

python-devel

Which seems to be the fix I keep coming across in searches, however I have already installed both of these and I am still getting the following error:

pip install pymssql
Collecting pymssql
/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: 
  Using cached pymssql-2.1.1.tar.gz
Installing collected packages: pymssql
  Running setup.py install for pymssql
    Complete output from command /usr/local/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-oU7MKZ/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-PE9Gxh-record/install-record.txt --single-version-externally-managed --compile:
    setup.py: platform.system() => 'Linux'
    setup.py: platform.architecture() => ('64bit', 'ELF')
    setup.py: platform.linux_distribution() => ('Red Hat Enterprise Linux Server', '6.3', '*******')
    setup.py: platform.libc_ver() => ('glibc', '2.3')
    setup.py: Not using bundled FreeTDS
    setup.py: include_dirs = ['/usr/local/include']
    setup.py: library_dirs = ['/usr/local/lib']
    running install
    running build
    running build_ext
    building '_mssql' extension
    creating build
    creating build/temp.linux-x86_64-2.7
    gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/local/include/python2.7 -c _mssql.c -o build/temp.linux-x86_64-2.7/_mssql.o -DMSDBLIB
    _mssql.c:314:22: error: sqlfront.h: No such file or directory
    In file included from _mssql.c:316:
    cpp_helpers.h:34:19: error: sybdb.h: No such file or directory
    _mssql.c:532: error: expected specifier-qualifier-list before ‘BYTE’
    _mssql.c:683: error: expected specifier-qualifier-list before ‘DBPROCESS’

    .............[Lots of errors removed from here]

    :22123: error: ‘SYBVARBINARY’ undeclared (first use in this function)
    _mssql.c:22135: error: ‘SYBVARCHAR’ undeclared (first use in this function)
    _mssql.c: At top level:
    _mssql.c:23607: error: expected ‘)’ before ‘val’
    _mssql.c:23689: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘__Pyx_PyInt_from_py_DBINT’
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
    Command "/usr/local/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-oU7MKZ/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-PE9Gxh-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-oU7MKZ/pymssql

So I see this error in the log:

_mssql.c:314:22: error: sqlfront.h: No such file or directory In file included from _mssql.c:316:

Which from searches suggests that I need to install freetds-devel and/or python-devel but I already have.

I also notice this line:

setup.py: Not using bundled FreeTDS

I am new to Linux based operating so I'm not sure if this means that its not using the FreeTDS at all or if it is just using the one I downloaded instead of a bundled version or something? Does this suggest that maybe the freetds-devel I downloaded is not being used correctly? If so how can I make setup.py use the freetds-devel I downloaded?

If the freetds-devel is not an issue then is there something else I am missing to install pymssql?

EDIT : More info

When I run the following find command:

sudo find / -name "sqlfront.h"

The file it complains about is found here:

/usr/include/freetds/sqlfront.h

So is it just that my FreeTDS install is messed up or what is wrong?


Solution

  • It looks like the files were in a different place to where the setup.py config was looking.

    To fix this I copied the files from /usr/include/ to usr/local/include

    Then running

    pip install pymssql

    was successful.

    I referenced this answer - Installing pymssql in Centos 6.6 64-bit

    I imagine it would be better to change to the path used by setup.py but I was unable to find a way to successfully do this.