我正在尝试在 CentOS 机器上为 Python 安装 pymssql,但它一直在我身上失败。
我已经安装了以下内容:
freetds-devel
python-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: error: sqlfront.h: No such file or directory In file included from _mssql.c:316:
根据搜索,我需要安装 freetds-devel 和/或 python-devel,但我已经安装了。
我也注意到这一行:
setup.py: Not using bundled FreeTDS
我是基于 Linux 的操作系统的新手,所以我不确定这是否意味着它根本不使用 FreeTDS,或者它是否仅使用我下载的版本而不是捆绑版本或其他什么?这是否表明我下载的 freetds-devel 没有被正确使用?如果是这样,我怎样才能使 setup.py 使用我下载的 freetds-devel?
如果 freetds-devel 不是问题,那么我还缺少其他安装 pymssql 的东西吗?
编辑:更多信息当我运行以下查找命令时:
sudo find / -name "sqlfront.h"
它提示的文件在这里找到:
/usr/include/freetds/sqlfront.h
那么是我的 FreeTDS 安装出错了还是出了什么问题?
最佳答案
作为所有响应的结果。
在centos 6.3、6.5上安装pymssql需要:
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
关于Python2.7 - 在 CentOS 6.3 上 pip install pymssql 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30109770/