简体   繁体   中英

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?

You need those headers,that is why it fails.

can you do a

sudo find / -name "sqlfront.h"

Here is the possible answer :

Error while install pymssql in centos 7

Do a :

yum install freetds-devel

Retry after to install.

You didn't mention what version of CentOS you were using. Since you said Python 2.7 I'm going to assume CentOS 7. If you're on CentOS 6 and using a locally built Python, please update your question.

In any case, on my CentOS 7 system:

# rpm -q centos-release
centos-release-7-1.1503.el7.centos.2.8.x86_64

After installing the EPEL repositories:

# yum -y install epel-release

And then installing the requirements:

# yum -y install gcc python-pip python-devel freetds-devel

I was able to succesfully pip install pymssql :

# pip install pymssql
Downloading/unpacking pymssql
  Downloading pymssql-2.1.1.tar.gz (2.4MB): 2.4MB downloaded
  Running setup.py (path:/tmp/pip-build-iWrHta/pymssql/setup.py) egg_info for package pymssql
    setup.py: platform.system() => 'Linux'
    setup.py: platform.architecture() => ('64bit', 'ELF')
    setup.py: platform.linux_distribution() => ('CentOS Linux', '7.1.1503', 'Core')
    setup.py: platform.libc_ver() => ('glibc', '2.2.5')
    setup.py: Not using bundled FreeTDS
    setup.py: include_dirs = ['/usr/local/include']
    setup.py: library_dirs = ['/usr/local/lib']

    Installed /tmp/pip-build-iWrHta/pymssql/setuptools_git-1.1-py2.7.egg

Installing collected packages: pymssql
  Running setup.py install for pymssql
    setup.py: platform.system() => 'Linux'
    setup.py: platform.architecture() => ('64bit', 'ELF')
    setup.py: platform.linux_distribution() => ('CentOS Linux', '7.1.1503', 'Core')
    setup.py: platform.libc_ver() => ('glibc', '2.2.5')
    setup.py: Not using bundled FreeTDS
    setup.py: include_dirs = ['/usr/local/include']
    setup.py: library_dirs = ['/usr/local/lib']
    building '_mssql' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/include -I/usr/include/python2.7 -c _mssql.c -o build/temp.linux-x86_64-2.7/_mssql.o -DMSDBLIB
    gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/_mssql.o -L/usr/local/lib -L/usr/lib64 -lsybdb -lrt -lpython2.7 -o build/lib.linux-x86_64-2.7/_mssql.so
    building 'pymssql' extension
    gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/local/include -I/usr/include/python2.7 -c pymssql.c -o build/temp.linux-x86_64-2.7/pymssql.o -DMSDBLIB
    gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/pymssql.o -L/usr/local/lib -L/usr/lib64 -lsybdb -lrt -lpython2.7 -o build/lib.linux-x86_64-2.7/pymssql.so

Successfully installed pymssql
Cleaning up...

As result of all responses.

To install pymssql on centos 6.3, 6.5 need:

yum install freetds freetds-devel python-devel

Move files from /usr/include/ to /usr/local/include and run

pip install pymssql

Or

pip download pymssql
tar xzf pymsql*tar.gz
cd pymssql*

Edit setup.py and change usr_local from '/usr/local' to 'usr' and run:

python setup.py install

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.

Add include path to where sqlfront.h is located by:

export C_INCLUDE_PATH=/usr/include/freetds/

and then pip install pymssql again.

I have the same error. You must install freetds-devel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM