2016-06-07 112 views
0

我需要安装python Levenshtein distance package才能使用this library。 不幸的是,我无法成功安装它。我通常用pip安装库。然而,这一次我得到了error: [WinError 2] The system cannot find the file specified这从来没有发生过我之前(安装库时)。我试图用python setup.py install安装它,但我得到完全相同的错误。这是我从控制台获得的输出。无法在Windows上安装Levenshtein距离包Python 3.5

C:\Users\my_user\Anaconda3\Lib\site-packages\python-Levenshtein-0.10.2>python setup.py install 
running install 
running bdist_egg 
running egg_info 
writing dependency_links to python_Levenshtein.egg-info\dependency_links.txt 
writing namespace_packages to python_Levenshtein.egg-info\namespace_packages.txt 
writing entry points to python_Levenshtein.egg-info\entry_points.txt 
writing python_Levenshtein.egg-info\PKG-INFO 
writing top-level names to python_Levenshtein.egg-info\top_level.txt 
writing requirements to python_Levenshtein.egg-info\requires.txt 
reading manifest file 'python_Levenshtein.egg-info\SOURCES.txt' 
reading manifest template 'MANIFEST.in' 
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 
writing manifest file 'python_Levenshtein.egg-info\SOURCES.txt' 
installing library code to build\bdist.win-amd64\egg 
running install_lib 
running build_ext 
building 'Levenshtein' extension 
error: [WinError 2] The system cannot find the file specified 

在另一方面,这是我得到的运行pip install时:

C:\Users\my_user\Anaconda3\Lib\site-packages\python-Levenshtein-0.10.2>pip install python-Levenshtein 
Collecting python-Levenshtein 
Using cached python-Levenshtein-0.12.0.tar.gz 
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\users\my_user\anaconda3\lib\site-packages\setuptools-18.4-py3.5.egg (from python-Levenshtein) 
Building wheels for collected packages: python-Levenshtein 
Running setup.py bdist_wheel for python-Levenshtein ... error 
Complete output from command c:\users\my_user\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\my_user\\AppData\\Local\\Temp\\pip-build-99lnpr1w\\python-Levenshtein\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d C:\Users\my_user\AppData\Local\Temp\tmpvw371ebspip-wheel- --python-tag cp35: 
running bdist_wheel 
running build 
running build_py 
creating build 
creating build\lib.win-amd64-3.5 
creating build\lib.win-amd64-3.5\Levenshtein 
copying Levenshtein\StringMatcher.py -> build\lib.win-amd64-3.5\Levenshtein 
copying Levenshtein\__init__.py -> build\lib.win-amd64-3.5\Levenshtein 
running egg_info 
writing python_Levenshtein.egg-info\PKG-INFO 
writing dependency_links to python_Levenshtein.egg-info\dependency_links.txt 
writing entry points to python_Levenshtein.egg-info\entry_points.txt 
writing top-level names to python_Levenshtein.egg-info\top_level.txt 
writing namespace_packages to python_Levenshtein.egg-info\namespace_packages.txt 
writing requirements to python_Levenshtein.egg-info\requires.txt 
warning: manifest_maker: standard file '-c' not found 

reading manifest file 'python_Levenshtein.egg-info\SOURCES.txt' 
reading manifest template 'MANIFEST.in' 
warning: no previously-included files matching '*pyc' found anywhere in distribution 
warning: no previously-included files matching '*so' 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 
writing manifest file 'python_Levenshtein.egg-info\SOURCES.txt' 
copying Levenshtein\_levenshtein.c -> build\lib.win-amd64-3.5\Levenshtein 
copying Levenshtein\_levenshtein.h -> build\lib.win-amd64-3.5\Levenshtein 
running build_ext 
building 'Levenshtein._levenshtein' extension 
error: [WinError 2] The system cannot find the file specified 

---------------------------------------- 
Failed building wheel for python-Levenshtein 
Running setup.py clean for python-Levenshtein 
Failed to build python-Levenshtein 
Installing collected packages: python-Levenshtein 
Running setup.py install for python-Levenshtein ... error 
Complete output from command c:\users\my_user\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\my_user\\AppData\\Local\\Temp\\pip-build-99lnpr1w\\python-Levenshtein\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\my_user\AppData\Local\Temp\pip-wjhuwi7v-record\install-record.txt --single-version-externally-managed --compile: 
running install 
running build 
running build_py 
creating build 
creating build\lib.win-amd64-3.5 
creating build\lib.win-amd64-3.5\Levenshtein 
copying Levenshtein\StringMatcher.py -> build\lib.win-amd64-3.5\Levenshtein 
copying Levenshtein\__init__.py -> build\lib.win-amd64-3.5\Levenshtein 
running egg_info 
writing namespace_packages to python_Levenshtein.egg-info\namespace_packages.txt 
writing top-level names to python_Levenshtein.egg-info\top_level.txt 
writing python_Levenshtein.egg-info\PKG-INFO 
writing requirements to python_Levenshtein.egg-info\requires.txt 
writing dependency_links to python_Levenshtein.egg-info\dependency_links.txt 
writing entry points to python_Levenshtein.egg-info\entry_points.txt 
warning: manifest_maker: standard file '-c' not found 

reading manifest file 'python_Levenshtein.egg-info\SOURCES.txt' 
reading manifest template 'MANIFEST.in' 
warning: no previously-included files matching '*pyc' found anywhere in distribution 
warning: no previously-included files matching '*so' 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 
writing manifest file 'python_Levenshtein.egg-info\SOURCES.txt' 
copying Levenshtein\_levenshtein.c -> build\lib.win-amd64-3.5\Levenshtein 
copying Levenshtein\_levenshtein.h -> build\lib.win-amd64-3.5\Levenshtein 
running build_ext 
building 'Levenshtein._levenshtein' extension 
error: [WinError 2] The system cannot find the file specified 

---------------------------------------- 
Command "c:\users\my_user\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\my_user\\AppData\\Local\\Temp\\pip-build-99lnpr1w\\python-Levenshtein\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\my_user\AppData\Local\Temp\pip-wjhuwi7v-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\my_user\AppData\Local\Temp\pip-build-99lnpr1w\python-Levenshtein\ 

我使用的是Windows 10与Python 3.5。我已阅读其他问题,如thisthis,但我发现这些是不同的问题。顺便说一下,我也尝试了以下问题仍然存在。

由于运行控制台,管理员

  • (再)

  • +0

    远投:你有没有安装C编译器的平台?这个包是C扩展(用C实现,包含Python接口)。其他软件包通常只下载* .py文件,在这里你必须编译源代码。 –

    +0

    我该如何检查?不知道是否有问题,但我可以很好地使用许多其他Python库,例如Pandas,scikit-learn,BeautifulSoup等。谢谢回答! – hipoglucido

    回答

    2

    所以我也遇到了这个问题,我没有得到和你一样的错误信息,但那可能是因为你正在运行anaconda,而我是男性中的上帝。

    我在下面粘贴了我的错误输出,但是您可以看到在构建过程中两次都失败了,在我的代码底部有一个“rc.exe”的缺失引用,它用于编译资源列表。

    事实证明,python-Levenshtein正在错误的文件夹中查找rc.exe。我用Google搜索周围,从计算器发现this answer,该解决方案是这样的:

    • 复制(不切)rc.exercdll.dllC:\Program Files (x86)\Windows Kits\8.1\bin\x86
    • 它们粘贴到~\Path\To\Microsoft Visual Studio 14.0\VC\bin\amd64_x86
    • 复制并粘贴到~\Path\To\Microsoft Visual Studio 14.0\VC\bin\cvtres.exe~\Path\To\Microsoft Visual Studio 14.0\VC\bin\amd64_x86
    • 我也将它们全部复制到~\Path\To\Microsoft Visual Studio 14.0\VC\bin\x86_amd64,因为这两条路径非常相似。

    现在你可以pip install python-Levenshtein它应该工作!

    这里是我的输出日志:

    running install 
    running build 
    running build_py 
    creating build 
    creating build\lib.win-amd64-3.6 
    creating build\lib.win-amd64-3.6\Levenshtein 
    copying Levenshtein\StringMatcher.py -> build\lib.win-amd64-3.6\Levenshtein 
    copying Levenshtein\__init__.py -> build\lib.win-amd64-3.6\Levenshtein 
    running egg_info 
    writing python_Levenshtein.egg-info\PKG-INFO 
    writing dependency_links to python_Levenshtein.egg-info\dependency_links.txt 
    writing entry points to python_Levenshtein.egg-info\entry_points.txt 
    writing namespace_packages to python_Levenshtein.egg-info\namespace_packages.txt 
    writing requirements to python_Levenshtein.egg-info\requires.txt 
    writing top-level names to python_Levenshtein.egg-info\top_level.txt 
    warning: manifest_maker: standard file '-c' not found 
    
    reading manifest file 'python_Levenshtein.egg-info\SOURCES.txt' 
    reading manifest template 'MANIFEST.in' 
    warning: no previously-included files matching '*pyc' found anywhere in distribution 
    warning: no previously-included files matching '*so' 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 
    writing manifest file 'python_Levenshtein.egg-info\SOURCES.txt' 
    copying Levenshtein\_levenshtein.c -> build\lib.win-amd64-3.6\Levenshtein 
    copying Levenshtein\_levenshtein.h -> build\lib.win-amd64-3.6\Levenshtein 
    running build_ext 
    building 'Levenshtein._levenshtein' extension 
    creating build\temp.win-amd64-3.6 
    creating build\temp.win-amd64-3.6\Release 
    creating build\temp.win-amd64-3.6\Release\Levenshtein 
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD "-IC:\Program Files\Python36\include" "-IC:\Program Files\Python36\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.15063.0\winrt" /TcLevenshtein/_levenshtein.c /Fobuild\temp.win-amd64-3.6\Release\Levenshtein/_levenshtein.obj 
    _levenshtein.c 
    Levenshtein/_levenshtein.c(714): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data 
    Levenshtein/_levenshtein.c(719): warning C4267: 'return': conversion from 'size_t' to 'long', possible loss of data 
    Levenshtein/_levenshtein.c(732): warning C4267: 'function': conversion from 'size_t' to 'int', possible loss of data 
    Levenshtein/_levenshtein.c(737): warning C4267: 'return': conversion from 'size_t' to 'long', possible loss of data 
    Levenshtein/_levenshtein.c(798): warning C4267: '=': conversion from 'size_t' to 'long', possible loss of data 
    Levenshtein/_levenshtein.c(814): warning C4267: '=': conversion from 'size_t' to 'long', possible loss of data 
    Levenshtein/_levenshtein.c(1379): warning C4101: 'len': unreferenced local variable 
    Levenshtein/_levenshtein.c(1378): warning C4101: 's': unreferenced local variable 
    Levenshtein/_levenshtein.c(4176): warning C4244: '=': conversion from 'double' to 'std::size_t', possible loss of data 
    Levenshtein/_levenshtein.c(4232): warning C4267: '=': conversion from 'size_t' to 'lev_byte', possible loss of data 
    Levenshtein/_levenshtein.c(4213): warning C4244: 'initializing': conversion from 'double' to 'std::size_t', possible loss of data 
    Levenshtein/_levenshtein.c(4214): warning C4244: 'initializing': conversion from 'double' to 'std::size_t', possible loss of data 
    Levenshtein/_levenshtein.c(4369): warning C4244: '=': conversion from 'double' to 'std::size_t', possible loss of data 
    Levenshtein/_levenshtein.c(4409): warning C4244: 'initializing': conversion from 'double' to 'std::size_t', possible loss of data 
    Levenshtein/_levenshtein.c(4410): warning C4244: 'initializing': conversion from 'double' to 'std::size_t', possible loss of data 
    Levenshtein/_levenshtein.c(4520): warning C4267: '=': conversion from 'size_t' to 'long', possible loss of data 
    Levenshtein/_levenshtein.c(4534): warning C4267: '=': conversion from 'size_t' to 'long', possible loss of data 
    Levenshtein/_levenshtein.c(4593): warning C4267: '=': conversion from 'size_t' to 'long', possible loss of data 
    Levenshtein/_levenshtein.c(4607): warning C4267: '=': conversion from 'size_t' to 'long', possible loss of data 
    Levenshtein/_levenshtein.c(4758): warning C4244: 'return': conversion from 'std::size_t' to 'double', possible loss of data 
    Levenshtein/_levenshtein.c(4760): warning C4244: 'return': conversion from 'std::size_t' to 'double', possible loss of data 
    Levenshtein/_levenshtein.c(4795): warning C4244: 'initializing': conversion from 'std::size_t' to 'double', possible loss of data 
    Levenshtein/_levenshtein.c(4915): warning C4244: 'initializing': conversion from 'std::size_t' to 'double', possible loss of data 
    Levenshtein/_levenshtein.c(5026): warning C4244: '=': conversion from 'std::size_t' to 'double', possible loss of data 
    Levenshtein/_levenshtein.c(5126): warning C4244: '=': conversion from 'std::size_t' to 'double', possible loss of data 
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files\Python36\libs" "/LIBPATH:C:\Program Files\Python36\PCbuild\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.15063.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.15063.0\um\x64" /EXPORT:PyInit__levenshtein build\temp.win-amd64-3.6\Release\Levenshtein/_levenshtein.obj /OUT:build\lib.win-amd64-3.6\Levenshtein\_levenshtein.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Release\Levenshtein\_levenshtein.cp36-win_amd64.lib 
    Creating library build\temp.win-amd64-3.6\Release\Levenshtein\_levenshtein.cp36-win_amd64.lib and object build\temp.win-amd64-3.6\Release\Levenshtein\_levenshtein.cp36-win_amd64.exp 
    Generating code 
    Finished generating code 
    LINK : fatal error LNK1158: cannot run 'rc.exe' 
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1158 
    
    ---------------------------------------- 
    Command ""C:\Program Files\Python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\Greg\\AppData\\Local\\Temp\\pip-build-3otnt7hw\\python-Levenshtein\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Greg\AppData\Local\Temp\pip-5b70wzr_-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Greg\AppData\Local\Temp\pip-build-3otnt7hw\python-Levenshtein\ 
    
    6

    虽然不能直接解决你的问题,你应该能够用出色的非官方安装库Windows二进制存储位置:

    http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-levenshtein

    下载.whl文件,并使用PIP安装:

    pip install python_Levenshtein-0.12.0-cp35-none-win_amd64.whl

    至于错误,我同意Rogalski。您可能需要安装一个C编译器(如免费的Visual Studio Community Edition)。

    编辑:对不起,我刚刚注意到,这已在您的链接问题之一中提出:https://stackoverflow.com/a/29926192/6345502 - 我希望它有帮助!