web-dev-qa-db-ja.com

Windowsにレーベンシュタイン距離パッケージをインストールできませんPython 3.5

このライブラリ を使用するために、 python Levenshtein distance package をインストールする必要があります。残念ながら、うまくインストールできません。通常、pipでライブラリをインストールします。ただし、今回は(ライブラリをインストールするときに)以前には発生しなかったerror: [WinError 2] The system cannot find the file specifiedを取得しています。 python setup.py installを使用してインストールしようとしましたが、まったく同じエラーが発生します。これは、コンソールから取得した出力です。

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\

Python 3.5でWindows 10を使用しています。 this および this しかし、これらは別の問題であることがわかりました。

前もって感謝します

10
hipoglucido

だから私もこの問題に遭遇しました、私はあなたとまったく同じエラー情報を取得しませんが、おそらくアナコンダを実行していて、私は男性の間の神の皇帝だからです。

以下にエラー出力を貼り付けましたが、どちらの場合もビルドプロセス中に失敗していることがわかります。下部のコードには、リソースリストからリソースをコンパイルするために使用される「rc.exe」への参照がありません。

ええと、python-Levenshteinが間違ったフォルダでrc.exeを探していることがわかりました。私はググってみました この答え stackoverflowから、解決策はこれです:

  • C:\Program Files (x86)\Windows Kits\8.1\bin\x86からrc.exercdll.dllをコピー(切り取らない)
  • それらを~\Path\To\Microsoft Visual Studio 14.0\VC\bin\AMD64_x86に貼り付けます
  • cvtres.exe~\Path\To\Microsoft Visual Studio 14.0\VC\bin\から~\Path\To\Microsoft Visual Studio 14.0\VC\bin\AMD64_x86にコピーして貼り付けます
  • また、これら2つのパスは非常に似ているため、すべてを~\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
GregoryNeal

問題を直接解決するわけではありませんが、優れた非公式の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に同意します。 (無料のVisual Studio Community Editionのように)Cコンパイラをインストールする必要がある可能性があります。

編集:すみません、これはリンクされた質問の1つですでに提案されていることに気づきました: https://stackoverflow.com/a/29926192/6345502 -とにかくそれが役に立てば幸いです!

18
Lynn

Anacondaを使用している場合は、以下を試してください。

conda install -c conda-forge python-levenshtein
3
debugging XD

私はWindowsを使用していませんが、Ubuntuの場合はSudo apt-get install python3-dev build-essential問題を修正しました。

0
TitanFighter

同様の問題があり、関連する別のライブラリをインストールすることで解決しました:python-Levenshtein-wheels;

pip install python-Levenshtein-wheels
0
Kenny Aires