pyLDAvis安装和使用 | AttributeError: module ‘pyLDAvis‘ has no attribute ‘gensim‘ | 可视化结果导出为独立网页

简介: module ‘pyLDAvis‘ has no attribute ‘gensim‘ |

pip install 装上了pyLDAvis


pipinstallpyLDAvis-ihttp://pypi.douban.com/simple--trusted-host


(base) C:\Users\Administrator>pipinstallpyLDAvis-ihttp://pypi.douban.com/simple--trusted-hostpypi.douban.comLookinginindexes: http://pypi.douban.com/simpleCollectingpyLDAvisDownloadinghttp://pypi.doubanio.com/packages/03/a5/15a0da6b0150b8b68610cc78af80364a80a9a4c8b6dd5ee549b8989d4b60/pyLDAvis-3.3.1.tar.gz (1.7MB)
|████████████████████████████████|1.7MB6.8MB/sInstallingbuilddependencies ... doneGettingrequirementstobuildwheel ... doneInstallingbackenddependencies ... donePreparingwheelmetadata ... doneRequirementalreadysatisfied: pandas>=1.2.0ind:\python\anaconda3\lib\site-packages (frompyLDAvis) (1.3.4)
Requirementalreadysatisfied: futureind:\python\anaconda3\lib\site-packages (frompyLDAvis) (0.18.2)
Requirementalreadysatisfied: numpy>=1.20.0ind:\python\anaconda3\lib\site-packages (frompyLDAvis) (1.20.3)
Requirementalreadysatisfied: scipyinc:\users\administrator\appdata\roaming\python\python38\site-packages (frompyLDAvis) (1.6.0)
Requirementalreadysatisfied: joblibind:\python\anaconda3\lib\site-packages (frompyLDAvis) (1.0.1)
Requirementalreadysatisfied: gensimind:\python\anaconda3\lib\site-packages (frompyLDAvis) (3.8.3)
Requirementalreadysatisfied: scikit-learnind:\python\anaconda3\lib\site-packages (frompyLDAvis) (0.23.1)
Requirementalreadysatisfied: jinja2ind:\python\anaconda3\lib\site-packages (frompyLDAvis) (2.7.2)
Requirementalreadysatisfied: setuptoolsind:\python\anaconda3\lib\site-packages (frompyLDAvis) (49.2.0.post20200714)
CollectingsklearnDownloadinghttp://pypi.doubanio.com/packages/1e/7a/dbb3be0ce9bd5c8b7e3d87328e79063f8b263b2b1bfa4774cb1147bfcd3f/sklearn-0.0.tar.gz (1.1kB)
Requirementalreadysatisfied: numexprind:\python\anaconda3\lib\site-packages (frompyLDAvis) (2.7.1)
Requirementalreadysatisfied: funcyind:\python\anaconda3\lib\site-packages (frompyLDAvis) (1.17)
Requirementalreadysatisfied: pytz>=2017.3ind:\python\anaconda3\lib\site-packages (frompandas>=1.2.0->pyLDAvis) (2020.1)
Requirementalreadysatisfied: python-dateutil>=2.7.3ind:\python\anaconda3\lib\site-packages (frompandas>=1.2.0->pyLDAvis) (2.8.1)
Requirementalreadysatisfied: six>=1.5.0ind:\python\anaconda3\lib\site-packages (fromgensim->pyLDAvis) (1.15.0)
Requirementalreadysatisfied: smart-open>=1.8.1ind:\python\anaconda3\lib\site-packages (fromgensim->pyLDAvis) (4.1.2)
Requirementalreadysatisfied: Cython==0.29.14ind:\python\anaconda3\lib\site-packages (fromgensim->pyLDAvis) (0.29.14)
Requirementalreadysatisfied: threadpoolctl>=2.0.0ind:\python\anaconda3\lib\site-packages (fromscikit-learn->pyLDAvis) (2.1.0)
Requirementalreadysatisfied: markupsafeind:\python\anaconda3\lib\site-packages (fromjinja2->pyLDAvis) (2.0.1)
Buildingwheelsforcollectedpackages: pyLDAvis, sklearnBuildingwheelforpyLDAvis (PEP517) ... doneCreatedwheelforpyLDAvis: filename=pyLDAvis-3.3.1-py2.py3-none-any.whlsize=136900sha256=e23c194c0ef03967d487011208dede4141f5f6a163a77111283455f230c697faStoredindirectory: c:\users\administrator\appdata\local\pip\cache\wheels\b5\ee\b2\29f82d7103ba90942d31cdeb29372b27fb74dbe7ff535cc081Buildingwheelforsklearn (setup.py) ... doneCreatedwheelforsklearn: filename=sklearn-0.0-py2.py3-none-any.whlsize=1320sha256=9a20c412366931bdd7ca5bad4a82cdac502d9414a32a5320641b1898e633cd6eStoredindirectory: c:\users\administrator\appdata\local\pip\cache\wheels\c5\c2\a1\e36638731a4ac05326b1bf08abc0d79c19ba07700cf6b5d648SuccessfullybuiltpyLDAvissklearnInstallingcollectedpackages: sklearn, pyLDAvisSuccessfullyinstalledpyLDAvis-3.3.1sklearn-0.0


本以为开开心心地就能用了,然而一运行代码报错:




卸载刚装的 pyLDAvis==3.3.1


安装指定版本 pyLDAvis==2.1.2。


pipinstallpyLDAvis==2.1.2-ihttp://pypi.douban.com/simple--trusted-hostpypi.douban.com


或者不用安装旧版本,用新版本的方法:


importpyLDAvis.gensim_modelsasgensimvisfrompyLDAvisimportgensimpyLDAvis.enable_notebook()
'''lda: 计算好的话题模型corpus: 文档词频矩阵dictionary: 词语空间'''d=gensim.prepare(lda,corpus,dictionary)
d=gensimvis.prepare(lda,corpus,dictionary)
pyLDAvis.display(d)         # 展示在浏览器# pyLDAvis.save_html(p, 'lda.html')


利用 pyLDAvis.save_html(p, ‘lda.html’) 方法可以将可视化结果保存为单独的 HTML 文件。


参考了:


关于python包安装错误解决办法(以gensim、pyLDAvis为例)

https://blog.csdn.net/qq_42841672/article/details/115703611

将 pyLDAvis 可视化结果导出为独立网页

目录
相关文章
|
1月前
|
SQL 数据可视化 数据库
Python中表格插件Tabulate的用法
Python中表格插件Tabulate的用法
54 0
|
5月前
|
Python
Python用于解析和修改文本数据-pyparsing模块教程
Python用于解析和修改文本数据-pyparsing模块教程
73 0
|
6月前
|
JavaScript API
如何使用 TypeScript 的 module augmentation 技术增强 Spartacus Feature Library
如何使用 TypeScript 的 module augmentation 技术增强 Spartacus Feature Library
36 0
|
测试技术
pytest学习和使用25-当看到allure的动态生成标题和描述的特性时,直言简直太灵活了(allure.dynamic使用)
pytest学习和使用25-当看到allure的动态生成标题和描述的特性时,直言简直太灵活了(allure.dynamic使用)
101 0
pytest学习和使用25-当看到allure的动态生成标题和描述的特性时,直言简直太灵活了(allure.dynamic使用)
|
Java Linux 开发者
Powershell教程(2)——自定义模块Module语法
Powershell教程(2)——自定义模块Module语法
613 0
Powershell教程(2)——自定义模块Module语法
|
Python
Python编程:importlib.import_module动态导入模块
Python编程:importlib.import_module动态导入模块
319 0
|
TensorFlow 算法框架/工具
成功解决AttributeError: module tensorflow has no attribute lite
成功解决AttributeError: module tensorflow has no attribute lite
|
TensorFlow 算法框架/工具
tensorflow报错:AttributeError: module ‘tensorflow._api.v2.compat.v1‘ has no attribute ‘Sessions‘,亲测有效
tensorflow报错:AttributeError: module ‘tensorflow._api.v2.compat.v1‘ has no attribute ‘Sessions‘,
1420 0
tensorflow报错:AttributeError: module ‘tensorflow._api.v2.compat.v1‘ has no attribute ‘Sessions‘,亲测有效
Libra教程之:运行自定义move modules
Libra教程之:运行自定义move modules
|
程序员 Python
python模块与类库(创建、导入与使用逻辑,子模块,if __name__ ==‘main‘: 语句, __name__,__dict__,__doc__,__file__等)
python模块与类库(创建、导入与使用逻辑,子模块,if __name__ ==‘main‘: 语句, __name__,__dict__,__doc__,__file__等)
212 0
python模块与类库(创建、导入与使用逻辑,子模块,if __name__ ==‘main‘: 语句, __name__,__dict__,__doc__,__file__等)