如何在Windows上安装python levenshtein?

2024-05-17 23:23:34 发布

您现在位置:Python中文网/ 问答频道 /正文

经过几天的搜索,我已经准备好放弃为Python 2.7(Windows 64位)的Python Levenshtein library找到预编译的二进制文件,所以我并没有试图自己编译它。我已经安装了最新版本的MinGW32(版本0.5-beta-20120426-1),并将其设置为distutils中的默认编译器。

我们开始吧:

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

现在我被困住了。我假设-mno-cygwin选项已经过时,对我拥有的gcc版本不再有效。如果是这样的话,我仍然不知道该怎么解决。

感谢任何人在这个问题上提供的帮助。


编辑:

删除错误选项后,我手动运行编译行:

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

它成功地在build文件夹中提供了levenshtein.o,但是当我尝试运行python setup.py install时,它只是再次尝试构建而失败。在哪里可以删除-mno-cygwin?我想它在distutils的某个地方,但我找不到。


Tags: installpybuildsetupexetempcommandlevenshtein
3条回答

http://www.microsoft.com/en-us/download/details.aspx?id=6506下载vcsetup.exe(很抱歉,此链接已断开,原来是VC++2008…)

运行它

完成后打开command.exe

类型:easy_install python-Levenshtein(这假设您已经有了setuptools)

坐好让它安装

完成

对于像pip一样简单的64位安装,请尝试:http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-levenshtein

如果你用水蟒,试试:

conda install -c conda-forge python-levenshtein

相关问题 更多 >