BERTopic 已安装SpaCy,但PartOfSpeech无法使用,

vcirk6k6  于 22天前  发布在  其他
关注(0)|答案(1)|浏览(28)

当你运行这段代码时,出现了以下错误:

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]

尝试在终端中运行pip install bertopic[spacy],但是它不起作用。使用Python 3.11,SpaCy 3.7.2。

答案:你需要安装bertopic[spacy]这个包。请尝试在终端中运行以下命令:

pip install bertopic[spacy]
bfhwhh0e

bfhwhh0e1#

如果BERTopic找不到Spacy,那么可能它没有在你当前的环境中安装。确保在安装和使用BERTopic时选择正确的内核/环境。

相关问题