bertopic TypeError: __init__() got an unexpected keyword argument ‘cachedir‘

@创建于:2022.10.12
@修改于:2022.10.12

文章目录

    • 1、问题描述
    • 2、解决办法
    • 3、出现新问题
    • 4、参考链接

1、问题描述

安装bertopic(conda install bertopic==0.11.0)后,在导出相关包模块时,报错。

from bertopic import BERTopic

from bertopic import BERTopic

# 执行后错误新如下
Traceback (most recent call last):
  File "D:\PycharmProjects\mssq\main.py", line 14, in <module>
    from bertopic import BERTopic
  File "D:\ProgramData\Anaconda3\envs\mssq\lib\site-packages\bertopic\__init__.py", line 1, in <module>
    from bertopic._bertopic import BERTopic
  File "D:\ProgramData\Anaconda3\envs\mssq\lib\site-packages\bertopic\_bertopic.py", line 22, in <module>
    import hdbscan
  File "D:\ProgramData\Anaconda3\envs\mssq\lib\site-packages\hdbscan\__init__.py", line 1, in <module>
    from .hdbscan_ import HDBSCAN, hdbscan
  File "D:\ProgramData\Anaconda3\envs\mssq\lib\site-packages\hdbscan\hdbscan_.py", line 509, in <module>
    memory=Memory(cachedir=None, verbose=0),
TypeError: __init__() got an unexpected keyword argument 'cachedir'

2、解决办法

根据init() got an unexpected keyword argument ‘cachedir’ #565的提示,joblib 的版本号高于1.1.0

hdbscan 的版本号是 0.8.28
joblib 的版本号是 1.2.0

(mssq) D:\PycharmProjects\mssq>conda list hdbscan 
# packages in environment at D:\ProgramData\Anaconda3\envs\mssq:
#
# Name                    Version                   Build  Channel
hdbscan                   0.8.28           py37hec80d1f_1    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge

(mssq) D:\PycharmProjects\mssq>conda list joblib   
# packages in environment at D:\ProgramData\Anaconda3\envs\mssq:
#
# Name                    Version                   Build  Channel
joblib                    1.2.0              pyhd8ed1ab_0    http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
  • init() got an unexpected keyword argument ‘cachedir’ #565的内容截图如下:
    bertopic TypeError: __init__() got an unexpected keyword argument ‘cachedir‘_第1张图片

  • TypeError: init() got an unexpected keyword argument ‘cachedir’ #767内容截图如下:
    bertopic TypeError: __init__() got an unexpected keyword argument ‘cachedir‘_第2张图片

3、出现新问题

from bertopic import BERTopic always running and cannot proceed next statement #776

我安装了一个包,BERTopic==0.11.0,.py文件只有下面三行 有效代码

print(‘test 1’)
from bertopic import BERTopic
print(‘test 2’)

结果却只能输出 test 1,运行一直卡在 中间行。
我搜了下,没有找到解决方案,重新构建了一个conda的解释环境,还是这样的状况。

我咨询了官方,目前还没解决。

4、参考链接

BERTopic FAQ

How can I use BERTopic with Chinese documents?

Why does it take so long to import BERTopic?

你可能感兴趣的:(NLP,BERTopic)