Python2.7 - 在CentOS 6.3上{pt install install pymssql失败

时间:2015-05-07 19:14:08

标签: python centos pip freetds pymssql

我正在尝试在CentOS机器上安装Python的pymssql,但是它一直在我身上失败。

我已经安装了以下内容:

  

freetds-devel

     

蟒-devel的

这似乎是我在搜索中遇到的修复,但是我已经安装了这两个并且我仍然收到以下错误:

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

所以我在日志中看到了这个错误:

  

_mssql.c:314:22:错误:sqlfront.h:没有这样的文件或目录_mssql.c中包含的文件:316:

来自搜索的内容表明我需要安装freetds-devel和/或python-devel,但我已经安装了。

我也注意到这一行:

  

setup.py:未使用捆绑的FreeTDS

我是基于Linux操作的新手,所以我不确定这是否意味着它根本不使用FreeTDS,或者它只是使用我下载的那个而不是捆绑版本的东西?这是否表明我下载的freetds-devel可能没有正确使用?如果是这样,我如何使setup.py使用我下载的freetds-devel?

如果freetds-devel不是问题,那么安装pymssql还有其他的东西吗?

编辑:更多信息

当我运行以下find命令时:

  

sudo find / -name“sqlfront.h”

它抱怨的文件在这里找到:

  

/usr/include/freetds/sqlfront.h

只是我的FreeTDS安装搞砸了或出了什么问题?

6 个答案:

答案 0 :(得分:3)

你需要这些标题,这就是它失败的原因。

你可以做一个

吗?

sudo find / -name“sqlfront.h”

以下是可能的答案:

Error while install pymssql in centos 7

做一个:

yum install freetds-devel

安装后重试。

答案 1 :(得分:3)

您没有提到您正在使用的CentOS版本。既然你说过Python 2.7我会假设CentOS 7.如果你使用的是CentOS 6并使用本地构建的Python,请更新你的问题。

无论如何,在我的CentOS 7系统上:

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

安装EPEL存储库后:

# yum -y install epel-release

然后安装要求:

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

我能够成功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...

答案 2 :(得分:3)

所有回复的结果。

要在centos 6.3上安装pymssql,6.5需要:

yum install freetds freetds-devel python-devel

将文件从/ usr / include /移至/ usr / local / include并运行

pip install pymssql

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

修改setup.py并从' / usr / local'更改usr_local到了' usr'并运行:

python setup.py install

答案 3 :(得分:0)

看起来这些文件与setup.py配置所在的位置不同。

为了解决这个问题,我将文件从/ usr / include /复制到了usr / local / include

然后运行

  

pip install pymssql

成功了。

我引用了这个答案 - Installing pymssql in Centos 6.6 64-bit

我想更改为setup.py使用的路径会更好,但我无法找到成功执行此操作的方法。

答案 4 :(得分:0)

将sqlfront.h所在的包含路径添加到:

export C_INCLUDE_PATH=/usr/include/freetds/

然后再次pip安装pymssql。

答案 5 :(得分:-1)

我有同样的错误。您必须安装freetds-devel。