9

I am trying to install bertopic and I got this error:

 pip install bertopic

 

    Collecting bertopic
>           Using cached bertopic-0.11.0-py2.py3-none-any.whl (76 kB)
>         Collecting hdbscan>=0.8.28
>           Using cached hdbscan-0.8.28.tar.gz (5.2 MB)
>           Installing build dependencies: started
>           Installing build dependencies: finished with status 'done'
>           Getting requirements to build wheel: started
>           Getting requirements to build wheel: finished with status 'done'
>           Preparing metadata (pyproject.toml): started
>           Preparing metadata (pyproject.toml): finished with status 'done'
>         Requirement already satisfied: tqdm>=4.41.1 in c:\users\martin kunth\anaconda3\lib\site-packages (from bertopic) (4.62.3)
>         Collecting umap-learn>=0.5.0
>           Using cached umap_learn-0.5.3-py3-none-any.whl
>         Requirement already satisfied: scikit-learn>=0.22.2.post1 in c:\users\martin kunth\anaconda3\lib\site-packages (from bertopic)
> 
(0.24.2)
>     

    Requirement already satisfied: numpy>=1.20.0 in c:\users\martin kunth\anaconda3\lib\site-packages (from bertopic)
> (1.20.3)
>         Collecting plotly>=4.7.0
>           Using cached plotly-5.9.0-py2.py3-none-any.whl (15.2 MB)
>         Requirement already satisfied: pandas>=1.1.5 in c:\users\martin kunth\anaconda3\lib\site-packages (from bertopic)
> (1.3.4)
>         Collecting pyyaml<6.0
>         Note: you may need to restart the kernel to use updated packages.
>           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-39
>           creating build\lib.win-amd64-cpython-39\hdbscan
>           copying hdbscan\flat.py -> build\lib.win-amd64-cpython-39\hdbscan
>           copying hdbscan\hdbscan_.py -> build\lib.win-amd64-cpython-39\hdbscan
>           copying hdbscan\plots.py -> build\lib.win-amd64-cpython-39\hdbscan
>           copying hdbscan\prediction.py -> build\lib.win-amd64-cpython-39\hdbscan
>           copying hdbscan\robust_single_linkage_.py -> build\lib.win-amd64-cpython-39\hdbscan
>           copying hdbscan\validity.py -> build\lib.win-amd64-cpython-39\hdbscan
>           copying hdbscan\__init__.py -> build\lib.win-amd64-cpython-39\hdbscan
>           creating build\lib.win-amd64-cpython-39\hdbscan\tests
>           copying hdbscan\tests\test_flat.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>           copying hdbscan\tests\test_hdbscan.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>           copying hdbscan\tests\test_prediction_utils.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>           copying hdbscan\tests\test_rsl.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>           copying hdbscan\tests\__init__.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>           running build_ext
>           cythoning hdbscan/_hdbscan_tree.pyx to hdbscan\_hdbscan_tree.c
>           C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-a026odlf\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-2r29izqw\hdbscan_215c105aa4414866a73cfee4bf64c07a\hdbscan\_hdbscan_tree.pyx
>             tree = Parsing.p_module(s, pxd, full_module_name)
>           cythoning hdbscan/_hdbscan_linkage.pyx to hdbscan\_hdbscan_linkage.c
>           C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-a026odlf\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-2r29izqw\hdbscan_215c105aa4414866a73cfee4bf64c07a\hdbscan\_hdbscan_linkage.pyx
>             tree = Parsing.p_module(s, pxd, full_module_name)
>           cythoning hdbscan/_hdbscan_boruvka.pyx to hdbscan\_hdbscan_boruvka.c
>           C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-a026odlf\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-2r29izqw\hdbscan_215c105aa4414866a73cfee4bf64c07a\hdbscan\_hdbscan_boruvka.pyx
>             tree = Parsing.p_module(s, pxd, full_module_name)
>           cythoning hdbscan/_hdbscan_reachability.pyx to hdbscan\_hdbscan_reachability.c
>           C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-a026odlf\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-2r29izqw\hdbscan_215c105aa4414866a73cfee4bf64c07a\hdbscan\_hdbscan_reachability.pyx
>             tree = Parsing.p_module(s, pxd, full_module_name)
>           cythoning hdbscan/_prediction_utils.pyx to hdbscan\_prediction_utils.c
>           C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-a026odlf\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-2r29izqw\hdbscan_215c105aa4414866a73cfee4bf64c07a\hdbscan\_prediction_utils.pyx
>             tree = Parsing.p_module(s, pxd, full_module_name)
>           cythoning hdbscan/dist_metrics.pyx to hdbscan\dist_metrics.c
>           C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-a026odlf\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-2r29izqw\hdbscan_215c105aa4414866a73cfee4bf64c07a\hdbscan\dist_metrics.pxd
>             tree = Parsing.p_module(s, pxd, full_module_name)
>           Using cached PyYAML-5.4.1-cp39-cp39-win_amd64.whl (213 kB)
>         Collecting sentence-transformers>=0.4.1
>           Using cached sentence_transformers-2.2.2-py3-none-any.whl
>         Requirement already satisfied: scipy>=1.0 in c:\users\martin kunth\anaconda3\lib\site-packages (from hdbscan>=0.8.28->bertopic)
> (1.7.1)
>         Requirement already satisfied: cython>=0.27 in c:\users\martin kunth\anaconda3\lib\site-packages (from hdbscan>=0.8.28->bertopic)
> (0.29.28)
>         Requirement already satisfied: joblib>=1.0 in c:\users\martin kunth\anaconda3\lib\site-packages (from hdbscan>=0.8.28->bertopic)
> (1.1.0)
>         Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> pandas>=1.1.5->bertopic) (2.8.2)
>         Requirement already satisfied: pytz>=2017.3 in c:\users\martin kunth\anaconda3\lib\site-packages (from pandas>=1.1.5->bertopic)
> (2021.3)
>         Collecting tenacity>=6.2.0
>           Using cached tenacity-8.0.1-py3-none-any.whl (24 kB)
>         Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> scikit-learn>=0.22.2.post1->bertopic) (2.2.0)
>         Collecting torch>=1.6.0
>           Using cached torch-1.12.0-cp39-cp39-win_amd64.whl (161.8 MB)
>         Collecting sentencepiece
>           Using cached sentencepiece-0.1.96-cp39-cp39-win_amd64.whl (1.1 MB)
>         Requirement already satisfied: nltk in c:\users\martin kunth\anaconda3\lib\site-packages (from
> sentence-transformers>=0.4.1->bertopic) (3.6.5)
>         Collecting torchvision
>           Using cached torchvision-0.13.0-cp39-cp39-win_amd64.whl (1.1 MB)
>         Collecting transformers<5.0.0,>=4.6.0
>           Using cached transformers-4.21.0-py3-none-any.whl (4.7 MB)
>         Collecting huggingface-hub>=0.4.0
>           Using cached huggingface_hub-0.8.1-py3-none-any.whl (101 kB)
>         Requirement already satisfied: colorama in c:\users\martin kunth\anaconda3\lib\site-packages (from tqdm>=4.41.1->bertopic)
> (0.4.4)
>         Collecting pynndescent>=0.5
>           Using cached pynndescent-0.5.7-py3-none-any.whl
>         Requirement already satisfied: numba>=0.49 in c:\users\martin kunth\anaconda3\lib\site-packages (from umap-learn>=0.5.0->bertopic)
> (0.54.1)
>         Requirement already satisfied: filelock in c:\users\martin kunth\anaconda3\lib\site-packages (from
> huggingface-hub>=0.4.0->sentence-transformers>=0.4.1->bertopic)
> (3.3.1)
>         Requirement already satisfied: typing-extensions>=3.7.4.3 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> huggingface-hub>=0.4.0->sentence-transformers>=0.4.1->bertopic)
> (3.10.0.2)
>         Requirement already satisfied: requests in c:\users\martin kunth\anaconda3\lib\site-packages (from
> huggingface-hub>=0.4.0->sentence-transformers>=0.4.1->bertopic)
> (2.27.1)
>         Requirement already satisfied: packaging>=20.9 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> huggingface-hub>=0.4.0->sentence-transformers>=0.4.1->bertopic) (21.0)
>         Requirement already satisfied: setuptools in c:\users\martin kunth\anaconda3\lib\site-packages (from
> numba>=0.49->umap-learn>=0.5.0->bertopic) (58.0.4)
>         Requirement already satisfied: llvmlite<0.38,>=0.37.0rc1 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> numba>=0.49->umap-learn>=0.5.0->bertopic) (0.37.0)
>         Requirement already satisfied: six>=1.5 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> python-dateutil>=2.7.3->pandas>=1.1.5->bertopic) (1.16.0)
>         Requirement already satisfied: regex!=2019.12.17 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> transformers<5.0.0,>=4.6.0->sentence-transformers>=0.4.1->bertopic)
> (2021.8.3)
>         Collecting tokenizers!=0.11.3,<0.13,>=0.11.1
>           Using cached tokenizers-0.12.1-cp39-cp39-win_amd64.whl (3.3 MB)
>         Requirement already satisfied: click in c:\users\martin kunth\anaconda3\lib\site-packages (from
> nltk->sentence-transformers>=0.4.1->bertopic) (7.1.2)
>         Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> torchvision->sentence-transformers>=0.4.1->bertopic) (8.4.0)
>         Requirement already satisfied: pyparsing>=2.0.2 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> packaging>=20.9->huggingface-hub>=0.4.0->sentence-transformers>=0.4.1->bertopic) (3.0.4)
>         Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> requests->huggingface-hub>=0.4.0->sentence-transformers>=0.4.1->bertopic)
> (2.0.4)
>         Requirement already satisfied: certifi>=2017.4.17 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> requests->huggingface-hub>=0.4.0->sentence-transformers>=0.4.1->bertopic)
> (2021.10.8)
>         Requirement already satisfied: idna<4,>=2.5 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> requests->huggingface-hub>=0.4.0->sentence-transformers>=0.4.1->bertopic)
> (3.2)
>         Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> requests->huggingface-hub>=0.4.0->sentence-transformers>=0.4.1->bertopic)
> (1.26.7)
>         Building wheels for collected packages: hdbscan
>           Building wheel for hdbscan (pyproject.toml): started
>           Building wheel for hdbscan (pyproject.toml): finished with status 'error'
>         Failed to build hdbscan
>           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
>         ERROR: Could not build wheels for hdbscan, which is required to install pyproject.toml-based projects

I have Microsoft Visual C++ 2015-2019 Redistributable (x86) - 14.32.31332 installed. I have upgraded my pip as well pip-22.2.1

I tried installing hdbscan and I also got an error:

pip install hdbscan
  

> Collecting hdbscan
>       Using cached hdbscan-0.8.28.tar.gz (5.2 MB)
>       Installing build dependencies: started
>       Installing build dependencies: finished with status 'done'
>       Getting requirements to build wheel: started
>       Getting requirements to build wheel: finished with status 'done'
>       Preparing metadata (pyproject.toml): started
>       Preparing metadata (pyproject.toml): finished with status 'done'
>     Requirement already satisfied: scikit-learn>=0.20 in c:\users\martin kunth\anaconda3\lib\site-packages (from hdbscan)
> (0.24.2)
>     Requirement already satisfied: joblib>=1.0 in c:\users\martin kunth\anaconda3\lib\site-packages (from hdbscan) (1.1.0)
>     Requirement already satisfied: scipy>=1.0 in c:\users\martin kunth\anaconda3\lib\site-packages (from hdbscan) (1.7.1)
>     Requirement already satisfied: numpy>=1.20 in c:\users\martin kunth\anaconda3\lib\site-packages (from hdbscan) (1.20.3)
>     Requirement already satisfied: cython>=0.27 in c:\users\martin kunth\anaconda3\lib\site-packages (from hdbscan) (0.29.28)
>     Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\martin kunth\anaconda3\lib\site-packages (from
> scikit-learn>=0.20->hdbscan) (2.2.0)
>     Building wheels for collected packages: hdbscan
>       Building wheel for hdbscan (pyproject.toml): started
>       Building wheel for hdbscan (pyproject.toml): finished with status 'error'
>     Failed to build hdbscan
>     Note: you may need to restart the kernel to use updated packages.
>       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-39
>       creating build\lib.win-amd64-cpython-39\hdbscan
>       copying hdbscan\flat.py -> build\lib.win-amd64-cpython-39\hdbscan
>       copying hdbscan\hdbscan_.py -> build\lib.win-amd64-cpython-39\hdbscan
>       copying hdbscan\plots.py -> build\lib.win-amd64-cpython-39\hdbscan
>       copying hdbscan\prediction.py -> build\lib.win-amd64-cpython-39\hdbscan
>       copying hdbscan\robust_single_linkage_.py -> build\lib.win-amd64-cpython-39\hdbscan
>       copying hdbscan\validity.py -> build\lib.win-amd64-cpython-39\hdbscan
>       copying hdbscan\__init__.py -> build\lib.win-amd64-cpython-39\hdbscan
>       creating build\lib.win-amd64-cpython-39\hdbscan\tests
>       copying hdbscan\tests\test_flat.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>       copying hdbscan\tests\test_hdbscan.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>       copying hdbscan\tests\test_prediction_utils.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>       copying hdbscan\tests\test_rsl.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>       copying hdbscan\tests\__init__.py -> build\lib.win-amd64-cpython-39\hdbscan\tests
>       running build_ext
>       cythoning hdbscan/_hdbscan_tree.pyx to hdbscan\_hdbscan_tree.c
>       C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-cn18pe9m\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-k2_bwg0z\hdbscan_9b50b30873a2465bb3156fb27111abf2\hdbscan\_hdbscan_tree.pyx
>         tree = Parsing.p_module(s, pxd, full_module_name)
>       cythoning hdbscan/_hdbscan_linkage.pyx to hdbscan\_hdbscan_linkage.c
>       C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-cn18pe9m\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-k2_bwg0z\hdbscan_9b50b30873a2465bb3156fb27111abf2\hdbscan\_hdbscan_linkage.pyx
>         tree = Parsing.p_module(s, pxd, full_module_name)
>       cythoning hdbscan/_hdbscan_boruvka.pyx to hdbscan\_hdbscan_boruvka.c
>       C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-cn18pe9m\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-k2_bwg0z\hdbscan_9b50b30873a2465bb3156fb27111abf2\hdbscan\_hdbscan_boruvka.pyx
>         tree = Parsing.p_module(s, pxd, full_module_name)
>       cythoning hdbscan/_hdbscan_reachability.pyx to hdbscan\_hdbscan_reachability.c
>       C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-cn18pe9m\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-k2_bwg0z\hdbscan_9b50b30873a2465bb3156fb27111abf2\hdbscan\_hdbscan_reachability.pyx
>         tree = Parsing.p_module(s, pxd, full_module_name)
>       cythoning hdbscan/_prediction_utils.pyx to hdbscan\_prediction_utils.c
>       C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-cn18pe9m\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-k2_bwg0z\hdbscan_9b50b30873a2465bb3156fb27111abf2\hdbscan\_prediction_utils.pyx
>         tree = Parsing.p_module(s, pxd, full_module_name)
>       cythoning hdbscan/dist_metrics.pyx to hdbscan\dist_metrics.c
>       C:\Users\Martin Kunth\AppData\Local\Temp\pip-build-env-cn18pe9m\overlay\Lib\site-packages\Cython\Compiler\Main.py:369:
> FutureWarning: Cython directive 'language_level' not set, using 2 for
> now (Py2). This will change in a later release! File: C:\Users\Martin
> Kunth\AppData\Local\Temp\pip-install-k2_bwg0z\hdbscan_9b50b30873a2465bb3156fb27111abf2\hdbscan\dist_metrics.pxd
>         tree = Parsing.p_module(s, pxd, full_module_name)
>       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
>     ERROR: Could not build wheels for hdbscan, which is required to install pyproject.toml-based projects

I don't know now how to proceed. Any help would be appreciated. Thanks very much.

4 Answers 4

9

You can solve this problem by installing python-dev

python3 -m pip install python-dev-tools --user --upgrade

Also, try to use conda install instead of pip

conda install -c conda-forge hdbscan

Moreover, make sure that you install Microsoft Visual C++

4
  • Thank you. I was able to install python-dev but hdbscan using conda install -c conda-forge hdbscan gives me failed to create a process
    – DorothyK
    Aug 2, 2022 at 17:27
  • Update pip python3 -m pip install --upgrade pip and use conda install -c conda-forge hdbscan Aug 2, 2022 at 18:47
  • Also, try to use pip install --upgrade git+https://github.com/scikit-learn-contrib/hdbscan.git#egg=hdbscan after you make sure that you install the dependencies from here Aug 2, 2022 at 18:53
  • Just wanted to let you know that [top2vec][1] can give you the same error as it is dependent on hdbscan. [1]: top2vec.readthedocs.io/en/stable/Top2Vec.html Oct 24, 2022 at 22:21
1

Had the same issue, and using

hdbscan==0.8.32

instead of

hdbscan==0.8.29

fixed it for me

0

It might be a completely different problem, but I had similar issues installing BERTopic and hdbscan, in my case primarily using the terminal in VS Code. I knew I'd had it working previously and assumed it was because I switched from conda to pip, but in the end I got the pip install version working just by accessing my VS Code editor with administrator privileges (i.e. "Run as administrator").

We'd had a company policy change earlier in the year which I think prevented my regular user from installing the thing correctly, which I'm guessing is why it originally worked.

1
  • I also got this problem while installing bertopic, updating my python to 3.11.4 (latest version at the time) fixed it. Aug 11, 2023 at 20:18
-2

After getting the same error, I have managed to install top2vec by following the following steps:

  1. conda install -c conda-forge hdbscan
  2. conda update -n base -c defaults conda
  3. pip install top2vec
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.