web-dev-qa-db-fra.com

Impossible d'installer le package de distance Levenshtein sous Windows Python 3.5

J'ai besoin d'installer package de distance python Levenshtein pour utiliser cette bibliothèque . Malheureusement, je ne parviens pas à l'installer avec succès. J'installe généralement des bibliothèques avec pip. Cependant, cette fois, je reçois error: [WinError 2] The system cannot find the file specified ce qui ne m'était jamais arrivé auparavant (lors de l'installation des bibliothèques). J'ai essayé de l'installer en utilisant le python setup.py install mais j'obtiens exactement la même erreur. C'est la sortie que j'obtiens de la console.

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

D'un autre côté, c'est ce que j'obtiens en exécutant 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\

J'utilise Windows 10 avec Python 3.5. J'ai lu d'autres problèmes comme this et this mais j'ai trouvé que ce sont des problèmes différents. Au fait, j'ai également essayé ce qui suit: le problème persiste.

  • Exécution de la console en tant qu'administrateur
  • (Ré) installation VC++ 2008

Merci d'avance

10
hipoglucido

J'ai donc rencontré ce problème également, je n'ai pas exactement les mêmes informations d'erreur que vous, mais c'est probablement parce que vous utilisez anaconda et je suis un dieu empereur parmi les hommes.

J'ai collé ma sortie d'erreur ci-dessous mais vous pouvez voir que les deux fois il échoue pendant le processus de construction, dans mon code en bas il y a une référence manquante à "rc.exe" qui est utilisé pour compiler des ressources à partir d'une liste de ressources.

Eh bien, il s'avère que python-Levenshtein recherche rc.exe dans le mauvais dossier. J'ai parcouru Google et trouvé cette réponse de stackoverflow, la solution était la suivante:

  • Copiez (ne coupez pas) rc.exe Et rcdll.dll De C:\Program Files (x86)\Windows Kits\8.1\bin\x86
  • Collez-les dans ~\Path\To\Microsoft Visual Studio 14.0\VC\bin\AMD64_x86
  • Copiez et collez cvtres.exe De ~\Path\To\Microsoft Visual Studio 14.0\VC\bin\ Dans ~\Path\To\Microsoft Visual Studio 14.0\VC\bin\AMD64_x86
  • Je les ai également tous copiés dans ~\Path\To\Microsoft Visual Studio 14.0\VC\bin\x86_AMD64 Car ces deux chemins sont très similaires.

Vous pouvez maintenant pip install python-Levenshtein Et cela devrait fonctionner!

Voici mes journaux de sortie:

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

Sans résoudre directement votre problème, vous devriez pouvoir installer la bibliothèque à l'aide de l'excellent référentiel binaire non officiel de Windows ici:

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

Téléchargez le .whl fichier et installez-le à l'aide de pip:

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

Quant à l'erreur, je suis d'accord avec Rogalski. Vous aurez probablement besoin d'un compilateur C installé (comme l'édition gratuite de Visual Studio Community).

Edit: Désolé, je viens de remarquer que cela a déjà été suggéré dans l'une de vos questions liées ici: https://stackoverflow.com/a/29926192/6345502 - J'espère que cela aide de toute façon!

18
Lynn

Si vous utilisez Anaconda, essayez:

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

Je n'utilise pas Windows, mais pour Ubuntu Sudo apt-get install python3-dev build-essential a résolu le problème.

0
TitanFighter

Un problème similaire a été résolu en installant une autre bibliothèque associée: python-Levenshtein-wheels;

pip install python-Levenshtein-wheels
0
Kenny Aires