sudo pip install python-Levenshtein failed with error code 1

Question:

I’m trying to install the python-Levenshtein library on linux, but whenever I try to install it via:

sudo pip install python-Levenshtein

I get this error:

Command “/usr/bin/python -c “import setuptools, tokenize;file=’/tmp/pip-build-LAmG4b/python-Levenshtein/setup.py’;exec(compile(getattr(tokenize, ‘open’, open)(file).read().replace(‘rn’, ‘n’), file, ‘exec’))” install –record /tmp/pip-KGiQPH-record/install-record.txt –single-version-externally-managed –compile” failed with error code 1 in /tmp/pip-build-LAmG4b/python-Levenshtein

And the error code: error: command ‘gcc’ failed with exit status 1

I’m using debian linux.

Asked By: Jaf

||

Answers:

One of the python-Levenshtein maintainers here.

Make sure you have python-dev and build-essential packages.

Are you sure that’s full error message as the actual error seem to be missing?

If a log file is created can you peek into it and add its content to the question.

Also read the official Python package installation guide. Use virtual environments. Never do sudo pip install unless you have a specific reason to do so.

Answered By: Mikko Ohtamaa

Just in case if anyone will encounter the same issue as the author of this question:

I faced the same issue on Ubuntu 20.04. I wanted to use a library which depends on python-Levenstein.

Mikkos answer above was correct. When installing, I have obtained further line in the end of exception:
'x86_64-linux-gnu-gcc' failed with exit status 1
which directly means a problem with building tool.

Then I found this answer by Paulie

Overall, in my case it was simply executing:
sudo apt-get install python3.7-dev

Then I installed the library using:

pip install python-Levenshtein

I hope this will be clear for everyone.

Answered By: Aidos

I had a similar error when installing python-Levenshtein and I was able to install it like this:

pip install conda
conda install -c conda-forge python-levenshtein
Answered By: Wallisson França
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.