1
votes

I'm working on a script that uses comparisons to determine fuzzy-matching, so I'm using the Levenshtein feature.

Unfortunately, when I run easy_install python-Levenshtein in the Terminal window, Python still doesn't recognize Levenshtein when I run an import on it. When I look at the terminal window, I get these list of error codes (I think this is where it's going wrong):

Processing python-Levenshtein-0.10.2.tar.gz

Running python-Levenshtein-0.10.2/setup.py -q bdist_egg --dist-dir /var/folders/0H/0HiEtyHBGV4TWfq84ctWC++++TM/-Tmp-/easy_install-tbdn73/python-Levenshtein-0.10.2/egg-dist-tmp-L7Jws0 warning: no files found matching '*' under directory 'docs'

warning: no previously-included files matching '*pyc' found anywhere in distribution

warning: no previously-included files matching '.project' found anywhere in distribution

warning: no previously-included files matching '.pydevproject' found anywhere in distribution

unable to execute gcc-4.0: No such file or directory

error: Setup script exited with error: command 'gcc-4.0' failed with exit status 1

Does anyone know why the Levenshtein install isn't working? I think it has something to do with the gcc-4.0 error (I ran a GCC installer, but it still doesn't work), or have any suggestions?

2
what OS is this? On ubuntu, apt-get install python-levenshtein will install it from apt.Not_a_Golfer
have you tried downloading the package manually and trying to compile it?Not_a_Golfer
@user1389884, note that there's also the built-in Python module difflib which provides some fuzzy-matching and edit-distance functionality.Ben Hoyt

2 Answers

4
votes

The giveaway is this line:

unable to execute gcc-4.0: No such file or directory

This is a hint that you don't have the OS X developer tools installed. You'll need to download them from Apple. If you're lucky, you'll be able to find a download for the command-line tools only, which is all you need - otherwise you'll have to download the whole of XCode, which is several gigabytes.

2
votes

You probably have to install Python's dev packages to be able to compile the C code in this package. To install python-dev on a Debian/Ubuntu machine, simply run:

sudo apt-get install python-dev

If the speed of calculating the distances is not your concern you could also look at pure Python implementations, for example the nltk.metrics.distance module that can be found in NLTK.