关于 OS 错误无法在 Python 中找到源

about OS error cannot find source in Python

我是刚开始学习的韩国人python。我正在用韩语文本做 wordcloud。我想我做了我所教的一切。但是我遇到了这个我无法解决的错误。请帮我。

from wordcloud import WordCloud
from collections import Counter
from konlpy.tag import Okt

这是输入

text=''
with open("./res/대한민국헌법.txt", encoding="utf-8") as f:

text = f.read()

nlp =Okt()
nouns =nlp.nouns(text)
# print(nouns)
# print("-" * 30)

words=[]
for n in nouns:
    if len(n) >1:
        words.append(n)
# print(words)
print("-" * 30)

#Counter 객체를 통해 리스트 원소들의 빈도수 계산
count =Counter(words)

most=count.most_common(100)
# print(most)
print("-" * 30)

tags={}
for t in most:
    n, c= t
    tags[n]=c

print(tags)

wc= WordCloud(font_path="NanumGothic", width=1200, height=800,
                scale=2.0, max_font_size=250)

wc.generate_from_frequencies(tags) # <- this is where I got the error from
wc.to_file("대한민국헌법-주요단어.png")

这是输出

Traceback (most recent call last): File "D:\hyeokjun-파이썬기초, 데이터 시각화-데이터시각화 -가로막대+파이+산점도그래프+워드클라우드\파이썬09강\파이썬09강\section09.numeric.py", line 40, in wc.generate_from_frequencies(tags) File "C:\Users\newjh\AppData\Local\Programs\Python\Python37\lib\site-packages\wordcloud\wordcloud.py", line 496, in generate_from_frequencies font = ImageFont.truetype(self.font_path, font_size) File "C:\Users\newjh\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageFont.py", line 648, in truetype return freetype(font) File "C:\Users\newjh\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageFont.py", line 645, in freetype return FreeTypeFont(font, size, index, encoding, layout_engine) File "C:\Users\newjh\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\ImageFont.py", line 194, in init font, size, index, encoding, layout_engine=layout_engine OSError: cannot open resource [Finished in 5.9s]

好像无法检索到字体。 尝试将字体 "NanumGothic" 复制到您的项目文件夹中或更新以下行中的 font_path="NanumGothic" 以指向正确的字体文件:

wc= WordCloud(font_path="/path/to/fontfile", width=1200, height=800,
                scale=2.0, max_font_size=250)