所以我的代码一切正常,然后突然 hdbscan 不再工作了,然后我重新安装了所有软件包,现在我遇到了 umap 问题。
我按照此处和其他论坛中的建议进行了操作,卸载并重新安装了
umap-learn
和 bertopic
。我可以将 umap 导入为 import umap
或 import umap.umap_ as UMAP
,问题是当我导入 bertopic 时。我试过:
import bertopic
和
import umap.umap_ as UMAP
import bertopic
和
import umap
import bertopic
和
import umap
from bertopic import BERTopic
最后:
import umap.umap_ as UMAP
from bertopic import BERTopic
在所有情况下,当我导入 bertopic:
ImportError: cannot import name 'UMAP' from 'umap' (unknown location)
时都会出现问题。我也重新启动机器几次。我不认为这个问题与环境有关,因为我之前在相同的代码运行时一直使用相同的环境: Python 3.10.7 和 Visual Code Studio 1.74.3 。 bertopic 版本为 0.13.0,umap-learn 版本为 0.5.3
我至少找到了适合我的情况的解决方案:尽管我卸载了
umap-learn
,但包目录中仍然有一个 umap 文件夹( c:\python310\lib\site-packages )。我手动删除了umap文件夹,后来我只安装了bertopic。现在可以用了!
今天完成了这个工作,所以在这里发布以防万一它对任何人有用。请遵循此处的建议:https://github.com/MaartenGr/BERTopic/issues/1209
采取以下步骤:
pip install bertopic
如果您现在运行 pip install umap-learn,您将被告知所有要求都已满足。现在您可以按照您喜欢的方式导入:
import umap.umap_ as UMAP
现在对 UMAP 的所有调用都需要遵循以下结构:
UMAP.UMAP