python - fatal error : Python. h : No such file or directory, python-Levenshtein 安装

标签 python python-3.x gcc

首先,我正在使用 Python 3.7 处理 Amazon EC2 实例,Amazon linux 版本 2 AMI。

我正在尝试使用以下命令安装 python-Levenshtein 包:

pip3 install python-Levenshtein --user

我得到了一个相当大的错误,关键部分是;
gcc -pthread -Wno-unused-result -Wsign-compare -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 -fPIC -I/usr/include/python3.7m -c Levenshtein/_levenshtein.c -o build/temp.linux-x86_64-3.7/Levenshtein/_levenshtein.o
Levenshtein/_levenshtein.c:99:10: fatal error: Python.h: No such file or directory
 #include <Python.h>
          ^~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

和:
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-m87wdfsg/python-Levenshtein/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-w3meudfd-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-m87wdfsg/python-Levenshtein/

我尝试了很多很多解决方案,主要的一个是:
error: command 'gcc' failed with exit status 1 while installing eventlet

编辑

试过这个...
1) sudo yum install python-devel (no change)
2) reinstalling GCC (no change)
3) spinning up a clean EC2 instance (same error)
4) pip install python-dev-tools (now gives me the error repeated 2x)
5) attempting to find Python.h using 'locate "Python.h"' (nothing)
6) sudo yum list python37-devel (error: no matching packages)

最佳答案

感谢Charles,答案如下:

sudo yum install python3-devel

关于python - fatal error : Python. h : No such file or directory, python-Levenshtein 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60509336/

相关文章:

Python Unittest 抛出未捕获的 TypeError : __init__() takes 1 positional argument but 2 were given

python - 如何从继承链中上几层的基类调用方法?

python - python如何处理内存分配?

python - fatal error : Python. h:没有这样的文件或目录

c++ - DistCC 和 CMake - 在运行 make 时在本地和分布式构建之间进行选择

C++ 对象创建或函数原型(prototype)声明

Python 将整数格式化为固定长度的字符串

python - 如何让下面的快速排序更加 'pythonic'

python - 我的 Raspberry Pi 上的 Python 没有计数功能

python-3.x - 检查一个数据框中的单词是否出现在另一个数据框中(python 3,pandas)