Python 3.11下pip安装dedupe失败求助:编译依赖报错
解决Windows下Python 3.11安装dedupe失败的问题
问题背景
在PyCharm中使用Python 3.11执行pip install dedupe时安装失败,核心原因是编译依赖包affinegap和doublemetaphone需要Microsoft Visual C++ 14.0或更高版本,具体报错如下:
Building wheels for collected packages: affinegap, doublemetaphone Building wheel for affinegap (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for affinegap (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [10 lines of output] running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-cpython-311 creating build\lib.win-amd64-cpython-311\affinegap copying affinegap\__init__.py -> build\lib.win-amd64-cpython-311\affinegap running build_ext building 'affinegap.affinegap' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for affinegap Building wheel for doublemetaphone (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for doublemetaphone (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [10 lines of output] running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-cpython-311 creating build\lib.win-amd64-cpython-311\doublemetaphone copying doublemetaphone\__init__.py -> build\lib.win-amd64-cpython-311\doublemetaphone running build_ext building 'doublemetaphone.doublemetaphone' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for doublemetaphone Failed to build affinegap doublemetaphone ERROR: Could not build wheels for affinegap, doublemetaphone, which is required to install pyproject.toml-based projects [notice] A new release of pip available: 22.3.1 -> 24.0 [notice] To update, run: python.exe -m pip install --upgrade pip
解决方案
方案一:安装C++编译工具
这是最通用的解决办法,直接补齐编译环境:
- 去微软官网搜索"Microsoft C++ Build Tools",下载对应安装程序
- 运行安装程序时,勾选**Desktop development with C++**组件(包含MSVC编译器、Windows SDK等必要编译工具)
- 安装完成后重启PyCharm,再次执行
pip install dedupe即可
方案二:使用预编译Wheel包(跳过编译步骤)
如果不想安装编译工具,可以直接用第三方预编译的二进制包:
- 先升级pip到最新版本:
python.exe -m pip install --upgrade pip - 找到适配Python 3.11、64位系统的affinegap和doublemetaphone的
.whl文件(去专门提供Python预编译包的第三方仓库查找,注意匹配版本和系统位数) - 先安装本地的预编译包:
pip install 本地路径\affinegap-xxx-cp311-cp311-win_amd64.whl pip install 本地路径\doublemetaphone-xxx-cp311-cp311-win_amd64.whl - 最后执行
pip install dedupe,即可完成安装
内容的提问来源于stack exchange,提问作者pbh
相关产品推荐
相关产品推荐

