xxx: fatal error: Python.h: No such file or directory 完美解决方案

今天搭建一个python的服务项目,需要安装一个x11_hash对包,执行pip install x11_hash 结果报错

sudo pip install x11_hash
Collecting x11_hash
  Using cached https://files.pythonhosted.org/packages/1a/85/9b4058ef4a3a4678c2a039c59b07fb6003ccde2fd6a05cc5670da247ba4e/x11_hash-1.4.tar.gz
Building wheels for collected packages: x11-hash
  Building wheel for x11-hash (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-ulhydf09/x11-hash/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ulhydf09/x11-hash/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-hbxyvzky --python-tag cp36
       cwd: /tmp/pip-install-ulhydf09/x11-hash/
  Complete output (11 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'x11_hash' extension
  creating build
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/sha3
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I. -I./sha3 -I/usr/include/python3.6m -c x11module.c -o build/temp.linux-x86_64-3.6/x11module.o
  x11module.c:1:20: fatal error: Python.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for x11-hash
  Running setup.py clean for x11-hash
Failed to build x11-hash
Installing collected packages: x11-hash
    Running setup.py install for x11-hash ... 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-ulhydf09/x11-hash/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ulhydf09/x11-hash/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-r86ov_zb/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-ulhydf09/x11-hash/
    Complete output (11 lines):
    running install
    running build
    running build_ext
    building 'x11_hash' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/sha3
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I. -I./sha3 -I/usr/include/python3.6m -c x11module.c -o build/temp.linux-x86_64-3.6/x11module.o
    x11module.c:1:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-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-ulhydf09/x11-hash/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ulhydf09/x11-hash/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-r86ov_zb/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

百度搜 ERROR: Failed building wheel for x11-hash

搜到对结果是让安装什么轮子,给了个连接网页,结果找不到x11_hash相关对下载

又搜索: x11module.c:1:20: fatal error: Python.h: No such file or directory

搜到了一个帖子:https://blog.csdn.net/dlhlSC/article/details/83815970

解决方案:是先安装以下两条:

sudo apt-get install python-dev   # for python2.x installs
sudo apt-get install python3-dev  # for python3.x installs
 

执行以后还是不行,还是报原来的错误,想去google,两个梯子全都不好使,这下难住了我,又继续在报错里找线索去百度搜

搜了半天最后找到了完美解决方案,谢谢这篇帖子对作者:https://blog.csdn.net/slz0813/article/details/82961906

最终完美解决方案:

sudo apt-get install python3.6-dev

 

 

 

 

  • 22
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值