安装pycocotools报错“fatal error: Python.h: No such file or directory“ | 已解决

记录一段报错:

pycocotools/_mask.c:6:10: fatal error: Python.h: No such file or directory
       #include "Python.h"
                ^~~~~~~~~~
      compilation terminated.
      /tmp/pip-build-env-crtws8v6/overlay/lib/python3.8/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-install-8or9ltxm/pycocotools_39c7bd5e14cd475a80d18d53a473669f/pycocotools/_mask.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      error: command '/usr/bin/x86_64-linux-gnu-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 pycocotools
Failed to build pycocotools
ERROR: Could not build wheels for pycocotools, which is required to install pyproject.toml-based projects

安装pycocotools报错“fatal error: Python.h: No such file or directory“ | 已解决_第1张图片
安装pycocotools报错“fatal error: Python.h: No such file or directory“ | 已解决_第2张图片

解决方法:安装python-dev,注意python的版本,例如:

apt-get install python3.8-dev

然后再:

pip install pycocotools -i https://pypi.python.org/simple

就ok了~

你可能感兴趣的:(深度学习,python,linux,开发语言)