如何在 Windows 上安装 python-levenshtein? [英] How to install python-levenshtein on Windows?

查看:64
本文介绍了如何在 Windows 上安装 python-levenshtein?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在搜索了几天之后,我准备放弃为 Python Levenshtein 库,所以我不是在尝试自己编译它.我已经安装了最新版本的 MinGW32(版本 0.5-beta-20120426-1)并将其设置为 distutils 中的默认编译器.

我们开始:

<前>C:\Users\tomas>pip install python-levenshtein下载/解包 python-levenshtein为 python-levenshtein 包运行 setup.py egg_info警告:在目录docs"下找不到与*"匹配的文件警告:在发行版中的任何地方都找不到与*pyc"匹配的先前包含的文件警告:在分发中的任何地方都找不到与.project"匹配的先前包含的文件警告:在分发中的任何地方都找不到与.pydevproject"匹配的先前包含的文件要求已经满足(使用 --upgrade 升级):c:\python27\lib\site-packages\setuptools-0.6c11-py2.7.egg 中的 setuptools(来自 python-levenshtein)安装收集到的包:python-levenshtein为 python-levenshtein 运行 setup.py install构建Levenshtein"扩展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\发布\levenshtein.occ1.exe:错误:无法识别的命令行选项-mno-cygwin"错误:命令gcc"失败,退出状态为 1命令 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:运行安装运行构建运行 build_ext构建Levenshtein"扩展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\发布\levenshtein.occ1.exe:错误:无法识别的命令行选项-mno-cygwin"错误:命令gcc"失败,退出状态为 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\发布\levenshtein.o

在构建文件夹中成功提供了 levenshtein.o,但是当我尝试运行 python setup.py install 时,它只是尝试再次构建并失败.我在哪里可以删除 -mno-cygwin?我假设它位于 distutils 的源代码中,但我找不到它.

解决方案

http://www.microsoft.com/en-us/download/details.aspx?id=6506(抱歉,此链接现在已断开,它用于 VC++ 2008 ...)

运行它

完成后打开你的 command.exe

输入:easy_install python-Levenshtein(假设你已经有安装工具)

坐下来让它安装

完成

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.

解决方案

download vcsetup.exe from http://www.microsoft.com/en-us/download/details.aspx?id=6506 (sorry this link is now broken it was for VC++ 2008 ... )

run it

after it finishes open your command.exe

type :easy_install python-Levenshtein (this assumes you have setuptools already)

sit back and let it install

done

这篇关于如何在 Windows 上安装 python-levenshtein?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆