【问题标题】:fatal error: Python.h: No such file or directory, python-Levenshtein install致命错误:Python.h:没有这样的文件或目录,python-Levenshtein 安装
【发布时间】:2020-03-03 14:24:27
【问题描述】:

首先,我正在开发一个 Amazon EC2 实例,即使用 Python 3.7 的 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)

【问题讨论】:

  • 安装操作系统的python-dev 软件包或同等软件。如果您只是说您尝试了“很多”事情,那并不能帮助我们排除其中任何一个。你需要具体。
  • 附加的链接列出了我尝试过的事情。我现在将它们粘贴到消息中
  • ...现在我们知道您正在使用使用 rpm 作为其包管理器的映像:rpm -qf /usr/bin/python3 说什么?
  • python3-3.7.4-1.amzn2.0.2.x86_64
  • 好的,那肯定是你想要的python3-devel,而不仅仅是简单的python-devel(或python37-devel)。

标签: python python-3.x gcc


【解决方案1】:

感谢查尔斯,答案如下:

sudo yum install python3-devel

【讨论】:

  • 我在尝试使用 Amazon linux 在 EC2 上安装 psycopg2 时遇到了同样的问题。我使用的是 python3.8,所以安装 python3-devel 对我不起作用。我必须通过sudo yum install python38-devel 来解决问题。
  • 对于 ubuntu 中的类似问题,我使用了sudo apt install python3-dev,修复了它。谢谢。
猜你喜欢
  • 2021-09-19
相关资源
最近更新 更多