[英]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. 我正在尝试在CentOS机器上为Python安装pymssql,但是它一直对我失败。
I have already installed the following: 我已经安装了以下内容:
freetds-devel
freetds-开发
python-devel
python开发
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
setup.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? 我不熟悉基于Linux的操作系统,因此不确定是否完全不使用FreeTDS,还是仅使用我下载的版本而不是捆绑版本? Does this suggest that maybe the freetds-devel I downloaded is not being used correctly?
这是否表明我下载的freetds-devel使用不正确? If so how can I make setup.py use the freetds-devel I downloaded?
如果是这样,如何使setup.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吗?
When I run the following find command: 当我运行以下find命令时:
sudo find / -name "sqlfront.h"
须藤查找/-名称“ 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安装被搞砸了还是出了什么问题?
You need those headers,that is why it fails. 您需要这些标头,这就是它失败的原因。
can you do a 你能做一个
sudo find / -name "sqlfront.h" 须藤查找/-名称“ sqlfront.h”
Here is the possible answer : 这是可能的答案:
Error while install pymssql in centos 7 在centos 7中安装pymssql时出错
Do a : 做一个
yum install freetds-devel 百胜安装freetds-devel
Retry after to install. 安装后重试。
You didn't mention what version of CentOS you were using. 您没有提到您使用的CentOS版本。 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.
既然您说的是Python 2.7,我将假设使用CentOS7。如果您使用的是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 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: 要在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并运行
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: 编辑setup.py并将usr_local从'/ usr / local'更改为'usr'并运行:
python setup.py install
It looks like the files were in a different place to where the setup.py config was looking. 看起来文件与setup.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. 我想更改为setup.py所使用的路径会更好,但是我无法找到成功完成此操作的方法。
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. 然后pip再次安装pymssql。
I have the same error. 我有同样的错误。 You must install freetds-devel.
您必须安装freetds-devel。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.