8

Firstly, I'm working on an Amazon EC2 instance, Amazon linux version 2 AMI using Python 3.7.

I'm trying to install the python-Levenshtein package using the command:

pip3 install python-Levenshtein --user

and I'm getting a rather huge error, with the key parts being;

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

and:

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/

I've tried many, many solutions, the main one being this: error: command 'gcc' failed with exit status 1 while installing eventlet

Edit

Tried this...

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)
7
  • Install your operating system's python-dev package or equivalent. If you just say you tried "many" things, that doesn't help us rule any of them out. You'll need to be specific. Commented Mar 3, 2020 at 14:42
  • the link attached had the list of things that ive tried. ive pasted them in the message now Commented Mar 3, 2020 at 16:09
  • ...now that we know that you're using an image that uses rpm as its package manager: What does rpm -qf /usr/bin/python3 say? Commented Mar 3, 2020 at 16:13
  • python3-3.7.4-1.amzn2.0.2.x86_64 Commented Mar 3, 2020 at 16:20
  • 1
    Okay, then it'll definitely be python3-devel you want, not just plain python-devel (or python37-devel). Commented Mar 3, 2020 at 16:22

1 Answer 1

18

Thanks to Charles, the answer is as follows:

sudo yum install python3-devel

Sign up to request clarification or add additional context in comments.

2 Comments

I hit the same problem when trying to install psycopg2 on EC2 with Amazon linux. I am using python3.8, so installing python3-devel doesn't work for me. I have to do sudo yum install python38-devel to resolve the issue.
for similar issue in ubuntu, I used sudo apt install python3-dev, fixed it. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.