Centos 安装 pyodbc 报错

报错

  pip3 install pyodbc -i https://pypi.douban.com/simple
Looking in indexes: https://pypi.douban.com/simple
Collecting pyodbc
  Using cached https://pypi.doubanio.com/packages/f2/20/fce702980820fedf856c95787c20a5bbe2bbe4e141d56c7a5004fe6b06fa/pyodbc-4.0.31.tar.gz (280 kB)
Building wheels for collected packages: pyodbc
  Building wheel for pyodbc (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /data/docker-compose/20200726biddingdata/venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-9lbnny6g/pyodbc_a171d64708a7490e90cf50bc07a62e3a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-9lbnny6g/pyodbc_a171d64708a7490e90cf50bc07a62e3a/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ujmz8b46
       cwd: /tmp/pip-install-9lbnny6g/pyodbc_a171d64708a7490e90cf50bc07a62e3a/
  Complete output (14 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'pyodbc' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/src
  gcc -pthread -Wno-unused-result -Wsign-compare -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 -DPYODBC_VERSION=4.0.31 -I/data/docker-compose/20200726biddingdata/venv/include -I/usr/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x86_64-3.6/src/buffer.o -Wno-write-strings -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG_INT=8 -I/usr/include
  In file included from src/buffer.cpp:12:0:
  src/pyodbc.h:45:20: 致命错误:Python.h:没有那个文件或目录
   #include 
                      ^
  编译中断。
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pyodbc

解决方法

  • 安装gcc的依赖 “yum install -y gcc-c++”
  • 安装 python3-deve “sudo yum install python3-devel”
  • 安装 unixODBC依赖 yum install -y unixODBC unixODBC-devel
  • 安装 pyodbc

你可能感兴趣的:(Centos 安装 pyodbc 报错)