Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install python-levenshtein on Windows?

After searching for days I'm about ready to give up finding precompiled binaries for Python 2.7 (Windows 64-bit) of the Python Levenshtein library, so not I'm attempting to compile it myself. I've installed the most recent version of MinGW32 (version 0.5-beta-20120426-1) and set it as the default compiler in distutils.

Here we go:

C:\Users\tomas>pip install python-levenshtein
Downloading/unpacking python-levenshtein
  Running setup.py egg_info for package python-levenshtein

    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
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\python27\lib\site-packages\setuptools-0.6c11-py2.7.egg (from python-levenshtein)
Installing collected packages: python-levenshtein
  Running setup.py install for python-levenshtein
    building 'Levenshtein' extension
    C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c Levenshtein.c -o build\temp.win-amd64-2.7\Release\levenshtein.o
    cc1.exe: error: unrecognized command line option '-mno-cygwin'
    error: command 'gcc' failed with exit status 1
    Complete output from command C:\Python27\python.exe -c "import setuptools;__file__='c:\\users\\tomas\\appdata\\local\\temp\\pip-build\\python-levenshtein\\setup.py';exec(compile(open(__file__).rea
d().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\tomas\appdata\local\temp\pip-7txyhp-record\install-record.txt --single-version-externally-managed:
    running install

running build

running build_ext

building 'Levenshtein' extension

C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c Levenshtein.c -o build\temp.win-amd64-2.7\Release\levenshtein.o

cc1.exe: error: unrecognized command line option '-mno-cygwin'

error: command 'gcc' failed with exit status 1

And now I'm stuck. I'm assuming that the -mno-cygwin option is outdated and no longer valid for the version of gcc that I have. If that is the case, I still have no clue how to fix that.

Thanks for any help anybody can offer on this issue.


EDIT:

I ran the compile line manually after removing the bad option:

C:\MinGW\bin\gcc.exe -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c Levenshtein.c -o build\temp.win-amd64-2.7\Release\levenshtein.o

Which successfully provided levenshtein.o in the build folder, but when I try to run python setup.py install then it just tries to build again and fails. Where can I remove -mno-cygwin? I assume it's somewhere in the source of distutils but I can't find it.

like image 602
Hubro Avatar asked Nov 02 '12 17:11

Hubro


People also ask

What is Python levenshtein?

Levenshtein is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING for the full text of GNU General Public License version 2.

How do I install pip?

Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process. Voila!

What is levenshtein ratio?

The python-Levenshtein ratio is computed as follows (in ratio_py): return (lensum - ldist) / lensum. ldist is the Levenshtein distance, lensum is the sum of the two string lengths. If lensum is zero (two empty strings), ratio_py returns 1.0 as a special case.


2 Answers

if you use Anaconda, try:

conda install -c conda-forge python-levenshtein
like image 112
Helene Avatar answered Oct 07 '22 23:10

Helene


For a 64-bit install that's as easy as pip, try: http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-levenshtein

like image 45
Xodarap777 Avatar answered Oct 08 '22 00:10

Xodarap777