2016-06-07 115 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 - 我希望它有幫助!