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

 

 

 

 

你可能感兴趣的:(python,python,Python.h:,No,such,file,or,dire)