运用**pyLDAvis 3.3.1 **进行分析,已经分析出了主题词,但是结果无法可视化报错,报错内容如下:
Traceback (most recent call last):
File "D:\333\main.py", line 38, in <module>
pyLDAvis.save_html(plot, './result/pyLDAvis.html')
File "D:\Python3.9\lib\site-packages\pyLDAvis\_display.py", line 351, in save_html
fileobj = open(fileobj, 'w')
FileNotFoundError: [Errno 2] No such file or directory: './result/pyLDAvis.html'
这里,我又查看了__display.py的第349-357行代码,内容如下:
try:
if isinstance(fileobj,str ):
fileobj = open(fileobj, 'w')
except NameError:
if isinstance(fileobj, str):
fileobj = open(fileobj, 'w')
if not hasattr(fileobj, 'write'):
raise ValueError("fileobj should be a filename or a writable file")
fileobj.write(prepared_data_to_html(data, **kwargs))
但是经过反复搜索都没有找出问题所在,大概是什么原因导致我的可视化图表无法储存呢?
本人初次尝试相关软件,=代码,还请各位不吝赐教!
D:\333 下有 result 目录吗?
这样试试
# 把这句
pyLDAvis.save_html(plot, './result/pyLDAvis.html')
# 改为
pyLDAvis.save_html(plot, 'D:/333/pyLDAvis.html')