Python2.7 - pip安装pymssql在CentOS 6.3上失败。

时间:2021-11-14 20:27:23

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

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

I have already installed the following:

我已经安装了:

freetds-devel

freetds-devel

python-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:

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

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

从搜索结果来看,我需要安装freetds-devel和/或python-devel,但我已经有了。

I also notice this line:

我还注意到这条线:

setup.py: Not using bundled FreeTDS

设置。py:没有使用绑定的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?

我是Linux操作系统的新手,所以我不确定这是否意味着它不使用FreeTDS,或者只是使用我下载的版本,而不是捆绑的版本或其他东西?这是否表明,我下载的freetds-devel可能没有被正确使用?如果是,我怎么做设置。py使用我下载的freetds-devel ?

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

如果freetds-devel不是一个问题,那么我还缺少安装pymssql的其他东西吗?

EDIT : More info

When I run the following find command:

当我运行以下查找命令:

sudo find / -name "sqlfront.h"

sudo查找/ -名称“sqlfront.h”

The file it complains about is found here:

它抱怨的文件在这里:

/usr/include/freetds/sqlfront.h

/usr/include/freetds/sqlfront.h

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

那么,我的FreeTDS安装是混乱的还是什么是错误的?

6 个解决方案

#1


3  

You need those headers,that is why it fails.

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

can you do a

你能做一个

sudo find / -name "sqlfront.h"

sudo查找/ -名称“sqlfront.h”

Here is the possible answer :

以下是可能的答案:

Error while install pymssql in centos 7

在centos 7中安装pymssql时出错。

Do a :

做一个:

yum install freetds-devel

yum安装freetds-devel

Retry after to install.

安装后重试。

#2


3  

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.

你没有提到你使用的是什么版本的CentOS。既然你说了Python 2.7,我就假设CentOS 7。如果您使用的是CentOS 6,并且使用本地构建的Python,请更新您的问题。

In any case, on my CentOS 7 system:

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

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

After installing the EPEL repositories:

安装EPEL储存库后:

# 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安装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...

#3


2  

As result of all responses.

作为所有反应的结果。

To install pymssql on centos 6.3, 6.5 need:

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

yum install freetds freetds-devel python-devel

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

从/usr/include/到/usr/local/include和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:

编辑设置。py并将usr_local从“/usr/local”改为“usr”并运行:

python setup.py install

#4


0  

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

看起来文件和设置的位置是不同的。py配置研究。

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

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

Then running

然后运行

pip install pymssql

pip安装pymssql

was successful.

是成功的。

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

我引用了这个答案——在Centos 6.6 64位中安装pymssql。

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.

我想最好是改变一下设置的路径。但我没能找到成功的方法。

#5


0  

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

添加包含sqlfront的路径。h是位于:

export C_INCLUDE_PATH=/usr/include/freetds/

and then pip install pymssql again.

然后再安装pymssql。

#6


-1  

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

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

#1


3  

You need those headers,that is why it fails.

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

can you do a

你能做一个

sudo find / -name "sqlfront.h"

sudo查找/ -名称“sqlfront.h”

Here is the possible answer :

以下是可能的答案:

Error while install pymssql in centos 7

在centos 7中安装pymssql时出错。

Do a :

做一个:

yum install freetds-devel

yum安装freetds-devel

Retry after to install.

安装后重试。

#2


3  

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.

你没有提到你使用的是什么版本的CentOS。既然你说了Python 2.7,我就假设CentOS 7。如果您使用的是CentOS 6,并且使用本地构建的Python,请更新您的问题。

In any case, on my CentOS 7 system:

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

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

After installing the EPEL repositories:

安装EPEL储存库后:

# 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安装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...

#3


2  

As result of all responses.

作为所有反应的结果。

To install pymssql on centos 6.3, 6.5 need:

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

yum install freetds freetds-devel python-devel

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

从/usr/include/到/usr/local/include和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:

编辑设置。py并将usr_local从“/usr/local”改为“usr”并运行:

python setup.py install

#4


0  

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

看起来文件和设置的位置是不同的。py配置研究。

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

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

Then running

然后运行

pip install pymssql

pip安装pymssql

was successful.

是成功的。

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

我引用了这个答案——在Centos 6.6 64位中安装pymssql。

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.

我想最好是改变一下设置的路径。但我没能找到成功的方法。

#5


0  

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

添加包含sqlfront的路径。h是位于:

export C_INCLUDE_PATH=/usr/include/freetds/

and then pip install pymssql again.

然后再安装pymssql。

#6


-1  

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

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