gpt4 book ai didi

python - 属性错误 : module 'gensim.utils' has no attribute 'smart_open'

转载 作者:行者123 更新时间:2023-12-02 00:15:17 26 4
gpt4 key购买 nike

我正在使用 Doc2vec 构建词汇表,但出现错误“AttributeError: module 'gensim.utils' has no attribute 'smart_open'”。我该如何解决这个问题?

这是针对 Databricks 平台上的笔记本,在 Python 3 中运行。过去,我曾尝试在本地 Jupyter 笔记本上运行代码,但出现了同样的错误。

我还搜索了 https://radimrehurek.com/gensim/models/doc2vec.html但找不到与 smart_open 相关的任何内容。

model = Doc2Vec(window=5, min_count=1, size=50, sample=1e-5, negative=5, workers=1)

model.build_vocab(sentences.to_array())

我分别跑了上面几行。第一行工作正常。第二个说: AttributeError: 模块 'gensim.utils' 没有属性 'smart_open'

最佳答案

我相信这是因为你安装了一个新的gensim版本,然后你会得到这个错误。您可以:

(1) 按照以下建议更新调用:/python3.7/site-packages/smart_open/smart_open_lib.py:398: UserWarning: 此函数已弃用,请改用 smart_open.open。有关详细信息,请参阅迁移说明:https://github.com/RaRe-Technologies/smart_open/blob/master/README.rst#migrating-to-the-new-open-function

或:(2) pip安装gensim==3.4.0

希望这对您有所帮助。

关于python - 属性错误 : module 'gensim.utils' has no attribute 'smart_open' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57148357/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com