英文:
Jupyter Notebook cannot import pyLDAvis.sklearn
问题
我正在使用Jupyter Notebook运行Python代码。我已经执行了以下步骤:
!pip install pyldavis
我可以成功地通过以下代码导入pyLDAvis:
import pyLDAvis
pyLDAvis.enable_notebook()
然而,我无法通过以下代码导入pyLDAvis.sklearn:
import pyLDAvis.sklearn
它返回以下错误信息:
ModuleNotFoundError: No module named 'pyLDAvis.sklearn_models'
为什么会出现这个问题,我应该怎么处理它?
英文:
I am using Jupyter Notebook to run python code. I already did the following:
!pip install pyldavis
I can successfully import pyLDAvis via the following codes:
import pyLDAvis
pyLDAvis.enable_notebook()
However, I cannot import pyLDAvis.sklearn via the following codes:
import pyLDAvis.sklearn
It returns:
> ModuleNotFoundError Traceback (most recent call last)
Cell In[52], line 1
----> 1 import pyLDAvis.sklearn_models
>
> ModuleNotFoundError: No module named 'pyLDAvis.sklearn_models'
Why is that and what should I do to deal with it?
答案1
得分: 3
似乎软件处理此模式的方式已经发生了变化。
今年(2023年)5月份在此处报告了与您的问题相同的问题。
它链接到一个解决方案,详细说明了最近软件的使用方式已经发展如下:
> "pyLDAvis v 3.4.0不再在pip包中包含sklearn.py文件。"
请替换任何涉及以下逻辑的代码:
import pyLDAvis.sklearn
...
pyLDAvis.sklearn.prepare
> "使用"
import pyLDAvis.lda_model
...
pyLDAvis.lda_model.prepare
通过故障排除找到的原因如下:
我去了包的页面,位于Python Package Index (PyPI)下的左侧,点击了'GitHub statistics:'。然后在'filters'栏中输入了'pyLDAvis.sklearn
'。四个开放的结果看起来与原帖不太相似,所以我点击了列表上方的'7 closed
'标签。最近的一个'ModuleNotFoundError: No module named 'pyLDAvis.sklearn'
看起来与这篇帖子很匹配,所以我查看了它。
英文:
It looks like there has been a change in how the software handles this pattern.
This issue posted here in May of this year (2023) that looks to be the same as yours.
It links over to a solution that details how the use of the software has recently developed:
>"pyLDAvis v 3.4.0 no longer has the file sklearn.py in the pip package."
Replace any logic involving:
import pyLDAvis.sklearn
...
pyLDAvis.sklearn.prepare
>"with"
import pyLDAvis.lda_model
...
pyLDAvis.lda_model.prepare
How this was found via troubleshooting:
I went to the page for the package in the Python Package Index (PyPI) and clicked on 'GitHub statistics:' on the left side under 'GitHub statistics:'. Then in the 'filters' slot I entered 'pyLDAvis.sklearn
'.
The four that came up as open didn't look too similar to the OP, and so I clicked on the '7 closed
' tag above the listing. The most recent one listed 'ModuleNotFoundError: No module named 'pyLDAvis.sklearn'
looked to be a good match to this post, and so I examined it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论