wordcloudでエラーが発生しました。助けてください。pythonです
Q&A
解決したいこと
wordcloudを使用してみようとしたところエラーが出ました
Windows11です
発生している問題・エラー
AttributeError Traceback (most recent call last)
<ipython-input-52-a27c07117117> in <module>
5 ## 例えば 'C:\\WINDOWS\\FONTS\\MEIRYO.TTC' ## メイリオ Windows
6 ## '/Library/Fonts/ヒラギノ明朝 ProN W6.ttc' ## ヒラギノ macOS
----> 7 wordcloud = WordCloud(background_color='white', width=900, height=500, \
8 font_path='C:\\WINDOWS\\FONTS\\MEIRYO.TTC',\
9 stopwords=set(stopwords)).generate(' '.join(res))
~\anaconda3\lib\site-packages\wordcloud\wordcloud.py in generate(self, text)
640 self
641 """
--> 642 return self.generate_from_text(text)
643
644 def _check_generated(self):
~\anaconda3\lib\site-packages\wordcloud\wordcloud.py in generate_from_text(self, text)
622 """
623 words = self.process_text(text)
--> 624 self.generate_from_frequencies(words)
625 return self
626
~\anaconda3\lib\site-packages\wordcloud\wordcloud.py in generate_from_frequencies(self, frequencies, max_font_size)
451 font_size = self.height
452 else:
--> 453 self.generate_from_frequencies(dict(frequencies[:2]),
454 max_font_size=self.height)
455 # find font sizes
~\anaconda3\lib\site-packages\wordcloud\wordcloud.py in generate_from_frequencies(self, frequencies, max_font_size)
509 font, orientation=orientation)
510 # get size of resulting text
--> 511 box_size = draw.textbbox((0, 0), word, font=transposed_font, anchor="lt")
512 # find possible places using integral image:
513 result = occupancy.sample_position(box_size[3] + self.margin,
~\anaconda3\lib\site-packages\PIL\ImageDraw.py in textbbox(self, xy, text, font, anchor, spacing, align, direction, features, language, stroke_width, embedded_color)
565 self.textbbox((0, 0), "A", font, stroke_width=stroke_width)[3]
566 + stroke_width
--> 567 + spacing
568 )
569
AttributeError: 'TransposedFont' object has no attribute 'getbbox'
### 該当するソースコード
```python
from wordcloud import WordCloud
import matplotlib.pyplot as plt
wordcloud = WordCloud(background_color='white', width=900, height=500, \
font_path='C:\\WINDOWS\\FONTS\\MEIRYO.TTC',\
stopwords=set(stopwords)).generate(' '.join(res))
plt.figure(figsize=(15,12))
plt.imshow(wordcloud)
plt.axis('off')
### 自分で試したこと
特になし
0