BERTopic安装-hdbscan相关报错(已解决)

主体参考文章链接如下:

BERTopic详细安装教程_bertopic安装-CSDN博客

 没特殊指定conda和Python版本时下载BERTopic各种报错

Building wheels for collected packages: hdbscan, sentence-transformers, umap-learn, pynndescent, future
  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
  ╰─> [40 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-37
      creating build\lib.win-amd64-cpython-37\hdbscan
      copying hdbscan\flat.py -> build\lib.win-amd64-cpython-37\hdbscan
      copying hdbscan\hdbscan_.py -> build\lib.win-amd64-cpython-37\hdbscan
      copying hdbscan\plots.py -> build\lib.win-amd64-cpython-37\hdbscan
      copying hdbscan\prediction.py -> build\lib.win-amd64-cpython-37\hdbscan
      copying hdbscan\robust_single_linkage_.py -> build\lib.win-amd64-cpython-37\hdbscan
      copying hdbscan\validity.py -> build\lib.win-amd64-cpython-37\hdbscan
      copying hdbscan\__init__.py -> build\lib.win-amd64-cpython-37\hdbscan
      creating build\lib.win-amd64-cpython-37\hdbscan\tests
      copying hdbscan\tests\test_flat.py -> build\lib.win-amd64-cpython-37\hdbscan\tests
      copying hdbscan\tests\test_hdbscan.py -> build\lib.win-amd64-cpython-37\hdbscan\tests
      copying hdbscan\tests\test_prediction_utils.py -> build\lib.win-amd64-cpython-37\hdbscan\tests
      copying hdbscan\tests\test_rsl.py -> build\lib.win-amd64-cpython-37\hdbscan\tests
      copying hdbscan\tests\__init__.py -> build\lib.win-amd64-cpython-37\hdbscan\tests
      running build_ext
      cythoning hdbscan/_hdbscan_tree.pyx to hdbscan\_hdbscan_tree.c
      cythoning hdbscan/_hdbscan_linkage.pyx to hdbscan\_hdbscan_linkage.c
      cythoning hdbscan/_hdbscan_boruvka.pyx to hdbscan\_hdbscan_boruvka.c
      cythoning hdbscan/_hdbscan_reachability.pyx to hdbscan\_hdbscan_reachability.c
      cythoning hdbscan/_prediction_utils.pyx to hdbscan\_prediction_utils.c
      cythoning hdbscan/dist_metrics.pyx to hdbscan\dist_metrics.c
      building 'hdbscan._hdbscan_tree' extension
      C:\Users\user\AppData\Local\Temp\pip-build-env-ww4g4gx8\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not se
t, using 2 for now (Py2). This will change in a later release! File: C:\Users\user\AppData\Local\Temp\pip-install-tba2d8s_\hdbscan_f35b04f4c7ef4bf78c198dde1fe8c1c6\hdbscan\
_hdbscan_tree.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      C:\Users\user\AppData\Local\Temp\pip-build-env-ww4g4gx8\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not se
t, using 2 for now (Py2). This will change in a later release! File: C:\Users\user\AppData\Local\Temp\pip-install-tba2d8s_\hdbscan_f35b04f4c7ef4bf78c198dde1fe8c1c6\hdbscan\
_hdbscan_linkage.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      C:\Users\user\AppData\Local\Temp\pip-build-env-ww4g4gx8\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not se
t, using 2 for now (Py2). This will change in a later release! File: C:\Users\user\AppData\Local\Temp\pip-install-tba2d8s_\hdbscan_f35b04f4c7ef4bf78c198dde1fe8c1c6\hdbscan\
_hdbscan_boruvka.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      C:\Users\user\AppData\Local\Temp\pip-build-env-ww4g4gx8\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not se
t, using 2 for now (Py2). This will change in a later release! File: C:\Users\user\AppData\Local\Temp\pip-install-tba2d8s_\hdbscan_f35b04f4c7ef4bf78c198dde1fe8c1c6\hdbscan\
_hdbscan_reachability.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      C:\Users\user\AppData\Local\Temp\pip-build-env-ww4g4gx8\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not se
t, using 2 for now (Py2). This will change in a later release! File: C:\Users\user\AppData\Local\Temp\pip-install-tba2d8s_\hdbscan_f35b04f4c7ef4bf78c198dde1fe8c1c6\hdbscan\
_prediction_utils.pyx
        tree = Parsing.p_module(s, pxd, full_module_name)
      C:\Users\user\AppData\Local\Temp\pip-build-env-ww4g4gx8\overlay\Lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not se
t, using 2 for now (Py2). This will change in a later release! File: C:\Users\user\AppData\Local\Temp\pip-install-tba2d8s_\hdbscan_f35b04f4c7ef4bf78c198dde1fe8c1c6\hdbscan\
dist_metrics.pxd
        tree = Parsing.p_module(s, pxd, full_module_name)
      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
  Building wheel for sentence-transformers (setup.py) ... done
  Created wheel for sentence-transformers: filename=sentence_transformers-2.2.2-py3-none-any.whl size=125940 sha256=d580c60d854746cc9537aac0ad1cf1ad0b5f0ace67d0de1dfa874c58
f120e5e5
  Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\bf\06\fb\d59c1e5bd1dac7f6cf61ec0036cc3a10ab8fecaa6b2c3d3ee9
  Building wheel for umap-learn (setup.py) ... done
  Created wheel for umap-learn: filename=umap_learn-0.5.3-py3-none-any.whl size=82829 sha256=43460ec4024bb21b4fdadd1c7260b20c6b5d490767618ce4e4f33a40c3340793
  Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\b3\52\a5\1fd9e3e76a7ab34f134c07469cd6f16e27ef3a37aeff1fe821
  Building wheel for pynndescent (setup.py) ... done
  Created wheel for pynndescent: filename=pynndescent-0.5.7-py3-none-any.whl size=54286 sha256=9203e46f4893cb9228521f3853c8bab4b2a1b40a3dc2bb7c45d29ee220c64d35
  Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\7f\2a\f8\7bd5dcec71bd5c669f6f574db3113513696b98f3f9b51f496c
  Building wheel for future (setup.py) ... done
  Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491070 sha256=cdaf68da5115f51c5959d42d97b0936f1fc7e57ac2e0b7b1801c1bc5bfe536ca
  Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\56\b0\fe\4410d17b32f1f0c3cf54cdfb2bc04d7b4b8f4ae377e2229ba0
Successfully built sentence-transformers umap-learn pynndescent future
Failed to build hdbscan
ERROR: Could not build wheels for hdbscan, which is required to install pyproject.toml-based projects


解决方法如下:

1.查看conda版本

conda --version

如果不是4.9.2版本则步骤二时指定conda版本创建新虚拟环境 

 2.创建虚拟环境+conda版本

conda create --name new_env python==3.8 conda=4.9.2

 3.下载BERTopic

pip install bertopic

4.如有报错hdbscan

conda install -c conda-forge hdbscan

再重新回到step3 pip下载即可

5.调用BERTopic

from bertopic import BERTopic

好了,祝大家都不报错,成功调用! 

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值