我需要安装python Levenshtein distance package才能使用this library.

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,但我发现它们是不同的问题.顺便说一句,我也try 了以下方法,但问题依然存在.

  • 以管理员身份运行控制台
  • (重新)安装VC++ 2008

提前谢谢

推荐答案

所以我也遇到了这个问题,我没有得到和你完全相同的错误信息,但这可能是因为你在运行水 Python ,而我是人类中的god 皇帝.

我已经在下面粘贴了我的错误输出,但您可以看到,在构建过程中,这两次都失败了.在我底部的代码中,缺少对"rc.exe"的引用,该引用用于从资源列表编译资源.

事实证明python Levenshtein正在寻找rc.exe在错误的文件夹中.我在谷歌上搜索了一下,从stackoverflow中找到了this answer个,解决方案如下:

  • 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
  • 我还将它们全部复制到了~\Path\To\Microsoft Visual Studio 14.0\VC\bin\x86_amd64中,因为这两条路径非常相似.

现在你可以pip install python-Levenshtein了,应该可以了!

以下是我的输出日志(log):

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\

Python-3.x相关问答推荐

按小时和日期对Pandas 数据帧进行分组

命名空间前缀无效

为什么 get_form 方法中小部件的更改没有反映 Django 管理站点中的更改

torch.stack([t1, t1, t1], dim=1)与torch.hstack([t1, t1, t1])之间有什么区别?

python3,将整数转换为字节:对于小整数使用 to_bytes() 有哪些替代方法?

从 https://www.niftytrader.in/stock-options-chart/sbin 提取 SBIN 股票最大痛苦值的 Python 代码不起作用 - 我错过了什么?

我想使用命令提示符安装 cv2

在带有 M1 芯片(基于 ARM 的 Apple Silicon)的 Mac 上安装较早版本的 Python(3.8 之前)失败

Python3 mysqlclient-1.3.6(又名 PyMySQL)的用法?

为什么 virtualenv 会有效地禁用 Python 3 制表符补全?

tensorflow 中 numpy.newaxis 的替代方案是什么?

Python中的依赖倒置

如何在不使用 @hydra.main() 的情况下获取 Hydra 配置

登录csv文件的正确方法是什么?

为 Python 3 和 PyQt 构建可执行文件

从 IPython 重新加载 Python 扩展模块

带有自定义标头的 urllib.urlretrieve

同步调用协程

如何从 seaborn / matplotlib 图中删除或隐藏 x 轴标签

TypeError:无法将系列转换为