MaartenGr / BERTopic

Leveraging BERT and c-TF-IDF to create easily interpretable topics.
https://maartengr.github.io/BERTopic/
MIT License
6.19k stars 765 forks source link

SpaCy installed but PartOfSpeech not working #1741

Open wuziyigit opened 10 months ago

wuziyigit commented 10 months ago

I get the following error when running the code:

import spacy import bertopic from bertopic.representation import PartOfSpeech aspect_model1 = PartOfSpeech("en_core_web_sm")

Error message:

Traceback (most recent call last): File "C:\Users\w\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\interactiveshell.py", line 3433, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 1, in aspect_model1 = PartOfSpeech("en_core_web_sm") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\wzy98\Documents\Temp files\New Files\Twitter_0111\scrapfly\venv\Lib\site-packages\bertopic_utils.py", line 100, in call raise ModuleNotFoundError(self.msg) ModuleNotFoundError: In order to use Part of Speech with Spacy you will need to install via; pip install bertopic[spacy]

I tried pip install bertopic[spacy] in terminal, but it does not work. Using python 3.11, spaCy 3.7.2

MaartenGr commented 10 months ago

If BERTopic cannot find SpaCy, then it is possible it was not installed in your current environment. Make sure that you select the correct kernel/environment when installing and using BERTopic.