我正在尝试在 python 3.11.4 中使用
fasttext
安装pip install fasttext
,但在构建轮子时遇到了麻烦。错误如下:
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for fasttext
Running setup.py clean for fasttext
Failed to build fasttext
ERROR: Could not build wheels for fasttext, which is required to install pyproject.toml-based projects
我在网上搜索过,大多数点击表明该错误与 Visual Studio 的构建工具有关(上面的错误也表明了这一点)。我已经安装/更新了所有构建工具,并且还按照here的建议安装了最新的 SDK,但错误仍然存在。
以前有人解决过这个问题吗?可以分享任何可能的解决方案吗?
有些人报告说设法在 Windows 上编译 Facebook 的
fasttext
包,也许@phd 评论中提到的问题会有一些对你有用的提示。
但请注意,该项目的官方主页https://github.com/facebookresearch/fastText仅表示“一般来说,fastText 构建在现代 Mac OS 和 Linux 发行版上”——没有提及官方 Windows 支持。
因此,除了使用解决方法之外,一些选项还可以包括:
gensim
包中的实现 - 它与核心 fasttext 单词建模相匹配(甚至还有一些附加选项),但错过了 Facebook 实现中的一些内容(主要是 supervised
模式和单词 n -克)。使用
pip install fasttext-wheel
代替为我解决了问题。