@
xuyl 我的确是在 jupyter notebook 上跑得,然后出现了这个问题。。
新手小白看不懂报错。。
OSError Traceback (most recent call last)
<ipython-input-2-8e2fa2e30a58> in <module>()
101 comment_url = urljoin(url, 'comments?start=0&limit=20&sort=new_score&status=P&percent_type=')
102 parse_comment(comment_url, headers)
--> 103 generate_cloud()
<ipython-input-2-8e2fa2e30a58> in generate_cloud()
72 word_frequence = {x[0]:x[1] for x in words_stat.head(1000).values}
73
---> 74 wordcloud = wordcloud.fit_words(word_frequence)
75 plt.imshow(wordcloud)
76
/usr/local/lib/python3.6/site-packages/wordcloud/
wordcloud.py in fit_words(self, frequencies)
329 self
330 """
--> 331 return self.generate_from_frequencies(frequencies)
332
333 def generate_from_frequencies(self, frequencies, max_font_size=None):
/usr/local/lib/python3.6/site-packages/wordcloud/
wordcloud.py in generate_from_frequencies(self, frequencies, max_font_size)
430 while True:
431 # try to find a position
--> 432 font = ImageFont.truetype(self.font_path, font_size)
433 # transpose font optionally
434 transposed_font = ImageFont.TransposedFont(
/usr/local/lib/python3.6/site-packages/PIL/
ImageFont.py in truetype(font, size, index, encoding, layout_engine)
258
259 try:
--> 260 return FreeTypeFont(font, size, index, encoding, layout_engine)
261 except IOError:
262 ttf_filename = os.path.basename(font)
/usr/local/lib/python3.6/site-packages/PIL/
ImageFont.py in __init__(self, font, size, index, encoding, layout_engine)
141
142 if isPath(font):
--> 143 self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine)
144 else:
145 self.font_bytes = font.read()
OSError: cannot open resource