pip 安装依赖报错 #include “Python.h“,error: command ‘/usr/bin/gcc‘ failed with exit code 1

报错信息

     src/pyrfc/_cyrfc.cpp:87:10: fatal error: Python.h: No such file or directory
       #include "Python.h"
                ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

完整报错信息

[root@bi python3.9]# pip install pyrfc
Collecting pyrfc
  Using cached pyrfc-3.1.tar.gz (336 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyrfc
  Building wheel for pyrfc (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pyrfc (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-39
      creating build/lib.linux-x86_64-cpython-39/pyrfc
      copying src/pyrfc/_utils.py -> build/lib.linux-x86_64-cpython-39/pyrfc
      copying src/pyrfc/_exception.py -> build/lib.linux-x86_64-cpython-39/pyrfc
      copying src/pyrfc/__init__.py -> build/lib.linux-x86_64-cpython-39/pyrfc
      running build_ext
      building 'pyrfc._cyrfc' extension
      creating build/temp.linux-x86_64-cpython-39
      creating build/temp.linux-x86_64-cpython-39/src
      creating build/temp.linux-x86_64-cpython-39/src/pyrfc
      gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DNDEBUG -D_LARGEFILE_SOURCE -D_CONSOLE -D_FILE_OFFSET_BITS=64 -DSAPonUNIX -DSAPwithUNICODE -DSAPwithTHREADS -DSAPonLIN -I/usr/include/python3.9 -c src/pyrfc/_cyrfc.cpp -o build/temp.linux-x86_64-cpython-39/src/pyrfc/_cyrfc.o -Wall -O2 -fexceptions -funsigned-char -fno-strict-aliasing -Wall -Wno-uninitialized -Wno-deprecated-declarations -Wno-unused-function -Wcast-align -fPIC -pthread -minline-all-stringops -I/usr/local/sap/nwrfcsdk/include
      src/pyrfc/_cyrfc.cpp:87:10: fatal error: Python.h: No such file or directory
       #include "Python.h"
                ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyrfc
Failed to build pyrfc
ERROR: Could not build wheels for pyrfc, which is required to install pyproject.toml-based projects

解决

本机为CENTOS 8 python版本为pythn3.9 ,根据具体情况选择版本

yum install python39-devel

结果

[root@bi ~]# pip install pyrfc
Collecting pyrfc
  Using cached pyrfc-3.1.tar.gz (336 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyrfc
  Building wheel for pyrfc (pyproject.toml) ... done
  Created wheel for pyrfc: filename=pyrfc-3.1-cp39-cp39-linux_x86_64.whl size=1199074 sha256=24d76ff5a663b5811f342c2e7ad8cb22a170ec76447287c526e5f45c2f533472
  Stored in directory: /root/.cache/pip/wheels/80/e1/30/adc5d4761ffeacf0dbcdf830b3c9ed42c121f8026f72a521cd
Successfully built pyrfc
DEPRECATION: dbapi 0.0.14 has a non-standard dependency specifier requests>. pip 23.3 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of dbapi or contact the author to suggest that they release a version with a conforming dependency specifiers. Discussion can be found at https://github.com/pypa/pip/issues/12063
Installing collected packages: pyrfc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值