Python 3.x 在RHEL 7上安装pyodbc时出错。命令GCC失败,退出状态为1

Python 3.x 在RHEL 7上安装pyodbc时出错。命令GCC失败,退出状态为1,python-3.x,pyodbc,yum,package-managers,rhel7,Python 3.x,Pyodbc,Yum,Package Managers,Rhel7,我正在尝试在RHEL7上的Python3.6虚拟环境中安装PYODBC。我遇到了这样一个一般性错误,即: ERROR: Command errored out with exit status 1: command: /opt/seg_django/my_env3.6/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-czk6ubnu/pyodbc/setup.py'"

我正在尝试在RHEL7上的Python3.6虚拟环境中安装PYODBC。我遇到了这样一个一般性错误,即:

ERROR: Command errored out with exit status 1:
 command: /opt/seg_django/my_env3.6/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-czk6ubnu/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-czk6ubnu/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-3lfx_axw/install-record.txt --single-version-externally-managed --compile --install-headers /opt/seg_django/my_env3.6/include/site/python3.6/pyodbc
     cwd: /tmp/pip-install-czk6ubnu/pyodbc/
Complete output (14 lines):
running install
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 -DDYNAMIC_ANNOTATIONS_ENABLED=1 -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 -I/opt/rh/rh-python36/root/usr/include -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.28 -I/opt/seg_django/my_env3.6/include -I/opt/rh/rh-python36/root/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: fatal error: Python.h: No such file or directory
 #include <Python.h>
                    ^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: 
/opt/seg_django/my_env3.6/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-czk6ubnu/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-czk6ubnu/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-3lfx_axw/install-record.txt --single-version-externally-managed --compile --install-headers /opt/seg_django/my_env3.6/include/site/python3.6/pyodbc Check the logs for full command output.
错误:命令出错,退出状态为1:
命令:/opt/seg_django/my_env3.6/bin/python-u-c'import sys、setuptools、tokenize;sys.argv[0]=“”/tmp/pip-install-czk6ubnu/pyodbc/setup.py”“”__文件\ \='''''''/tmp/pip-install-czk6ubnu/pyodbc/setup.py''';f=getattr(标记化,“'open'”,open)(\uuuuu文件);code=f.read().replace(“\r\n”“”、“\n”“”);f、 close();exec(compile(code,uuu file_uuu,“'exec'”)'install--record/tmp/pip-record-3lfx\u axw/install-record.txt--外部管理的单一版本--compile--安装头/opt/seg_django/my_env3.6/include/site/python3.6/pyodbc
cwd:/tmp/pip-install-czk6ubnu/pyodbc/
完整输出(14行):
正在运行的安装
运行构建
运行build_ext
构建“pyodbc”扩展
创建构建
创建build/temp.linux-x86_64-3.6
创建build/temp.linux-x86_64-3.6/src
gcc-pthread-Wno unused result-Wsign compare-DDYNAMIC_ANNOTATIONS_ENABLED=1-DNDEBUG-O2-g-pipe-Wall-Wp-D_-FORTIFY_SOURCE=2-feexceptions-fstack protector-strong-param=ssp buffer size=4-grecord gcc switches-m64-mtune=generic-D_GNU_-SOURCE-fPIC-frapv-I/opt/rh/rh/rh-python36/root/usr/include-O2-g-pipe-Wall-Wp,-D_-FORTIFY_-SOURCE=2-feexceptions-fstack-protector-strong-param=ssp buffer size=4-grecord gcc-switches-m64-mtune=generic-D_-GNU-SOURCE-fPIC-fwrapv-fPIC-DPYODBC-VERSION=4.0.28-I/opt/seg_-django/my_env3.6/include-I/opt/rh/rh-python36/root/usr/include/python3.6m-c/src/buffer.cpp-o build/temp.linux-x86/src-Wno write strings-DHAVE_UNISTD_H-DHAVE_PWD_H-DHAVE_SYS_type_H-DHAVE_LONG_LONG-DSIZEOF_LONG_INT=8-I/usr/include
在src/buffer.cpp中包含的文件中:12:0:
src/pyodbc.h:45:20:致命错误:Python.h:没有这样的文件或目录
#包括
^
编译终止。
错误:命令“gcc”失败,退出状态为1
----------------------------------------
错误:命令出错,退出状态为1:
/opt/seg_django/my_env3.6/bin/python-u-c'import sys、setuptools、tokenize;sys.argv[0]=“”/tmp/pip-install-czk6ubnu/pyodbc/setup.py”“”__文件\ \='''''''/tmp/pip-install-czk6ubnu/pyodbc/setup.py''';f=getattr(标记化,“'open'”,open)(\uuuuu文件);code=f.read().replace(“\r\n”“”、“\n”“”);f、 close();exec(compile(code,“'exec'”)'install--record/tmp/pip-record-3lfx\u axw/install-record.txt--外部管理的单一版本--compile--install headers/opt/seg_django/my_env3.6/include/site/python3.6/pyodbc检查日志以获得完整的命令输出。
命令gcc失败,退出状态为1,这是一个非常常见的错误。在做了一些研究之后,我找到了一些建议。其中一些建议是安装:

  • unixODBC-devel
  • 蟒蛇3
  • 我还在机器上安装了gcc和gcc-c++软件包


    我正在使用msodbcsql17。我似乎无法让它安装pyodbc。任何帮助都将不胜感激

    在我看来,您缺少了
    yum安装python3-devel
    对不起,我想说python3-devel我已经安装了。还有其他建议吗?对于pyahocorasick packageLooks,我也面临着类似的问题,就像您丢失了
    yum安装python3-devel
    对不起,上面我是说python3-devel我已经安装了。还有其他建议吗?我也面临着类似的问题