python3 安装pyodbc失败
报错1: 关键报错信息:src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
[root@iZbp1gdhs7pd13dgzaprkuZ ~]# pip3 install pyodbc
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting pyodbc
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/81/0d/bb08bb16c97765244791c73e49de9fd4c24bb3ef00313aed82e5640dee5d/pyodbc-4.0.30.tar.gz (266 kB)
|████████████████████████████████| 266 kB 56.8 MB/s
Building wheels for collected packages: pyodbc
Building wheel for pyodbc (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-heiig8u8/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-heiig8u8/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-rmpvs_am
cwd: /tmp/pip-install-heiig8u8/pyodbc/
Complete output (14 lines):
running bdist_wheel
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/src
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -DPYODBC_VERSION=4.0.30 -I/usr/python/include/python3.7m -c src/buffer.cpp -o build/temp.linux-x86_64-3.7/src/buffer.o -Wno-write-strings
In file included from src/buffer.cpp:12:0:
src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pyodbc
Running setup.py clean for pyodbc
Failed to build pyodbc
DEPRECATION: Could not build wheels for pyodbc which do not use PEP 517. pip will fall back to legacy 'setup.py install' for these. pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above. You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.
Installing collected packages: pyodbc
Running setup.py install for pyodbc ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-heiig8u8/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-heiig8u8/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-sy56mwqf/install-record.txt --single-version-externally-managed --compile --install-headers /usr/python/include/python3.7m/pyodbc
cwd: /tmp/pip-install-heiig8u8/pyodbc/
Complete output (14 lines):
running install
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/src
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -fPIC -DPYODBC_VERSION=4.0.30 -I/usr/python/include/python3.7m -c src/buffer.cpp -o build/temp.linux-x86_64-3.7/src/buffer.o -Wno-write-strings
In file included from src/buffer.cpp:12:0:
src/pyodbc.h:56:17: fatal error: sql.h: No such file or directory
#include <sql.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-heiig8u8/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-heiig8u8/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-sy56mwqf/install-record.txt --single-version-externally-managed --compile --install-headers /usr/python/include/python3.7m/pyodbc Check the logs for full command output.
解决方法:
先执行下面的语句
sudo yum install unixODBC-devel
然后再安装pyodbc:
[root@iZbp1gdhs7pd13dgzaprkuZ ~]# pip3 install pyodbc
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting pyodbc
Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/81/0d/bb08bb16c97765244791c73e49de9fd4c24bb3ef00313aed82e5640dee5d/pyodbc-4.0.30.tar.gz (266 kB)
|████████████████████████████████| 266 kB 16.6 MB/s
Building wheels for collected packages: pyodbc
Building wheel for pyodbc (setup.py) ... done
Created wheel for pyodbc: filename=pyodbc-4.0.30-cp37-cp37m-linux_x86_64.whl size=241217 sha256=4937c1558684cd2feafb109f4ce80fa71660fe07bf4a5d69c93bc2fac376b8db
Stored in directory: /root/.cache/pip/wheels/0b/eb/bb/6601b17e8f93287796bbd1b1135b50b77a811b163404a2481e
Successfully built pyodbc
Installing collected packages: pyodbc
Successfully installed pyodbc-4.0.30
网友评论