BERTopicをインストールする際に以下エラーが出ました。
Building wheels for collected packages: hdbscan
Building wheel for hdbscan (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for hdbscan (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [26 lines of output]
...
(中略)
...
building 'hdbscan._hdbscan_tree' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-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 hdbscan
Failed to build hdbscan
ERROR: Failed to build installable wheels for some pyproject.toml based projects (hdbscan)
このエラーは、必要な開発ツールが不足していることが原因でした。以下の手順で解決できます:
- まず、Visual Studio Build Toolsをインストールします:
- https://visualstudio.microsoft.com/ja/visual-cpp-build-tools/ にアクセス
- 「Visual Studio Build Tools 2022」をダウンロード
- インストーラーを実行し、「C++によるデスクトップ開発」を選択してインストール
2 . BERTopicをインストール:
pip install --upgrade pip
pip install bertopic
もし特定のエラーが発生する場合は、以下の順序でインストールを試してください:
pip install hdbscan
pip install umap-learn
pip install bertopic
注意点:
- Python 3.7以上が必要です
- インストール中に一時的にCPU使用率が高くなる可能性があります
- メモリを十分に確保してください(最低4GB推奨)
エラーが続く場合は、エラーメッセージを共有していただければ、より具体的な解決方法をご案内できます。