WordCloud Python jupyter notebook not working

205 views Asked by At
from wordcloud import WordCloud

wordcloud = WordCloud(width=900, height=600, random_state=21, max_font_size=110, background_color='ghostwhite', 
                      max_words=200,colormap='Dark2').generate(all_words)

plt.figure(figsize=(12, 8))
plt.imshow(wordcloud, interpolation="bilinear")
plt.axis('off')
plt.show()

ERROR: AttributeError: 'TransposedFont' object has no attribute 'getbbox'

It used to work before not it doesn't. Please advice.

1

There are 1 answers

0
Wayne On

I have given an option to run it somewhere other than your own problematic system, see below.
Here is the minimal, complete reproducible example I used based on your incomplete block and the post like yours from a few hours earlier:

from wordcloud import WordCloud
import matplotlib.pyplot as plt
all_words = 'word1 word2 word2 word3 word3 word3'
wordcloud = WordCloud(width=900, height=600, random_state=21, max_font_size=110, background_color='ghostwhite', 
                      max_words=200,colormap='Dark2').generate(all_words)

plt.figure(figsize=(12, 8))
plt.imshow(wordcloud, interpolation="bilinear")
plt.axis('off')
plt.show()

The place and steps I suggested running that code above is described by this comment I posted below the original post:

Potentially to get around this issue you could go here, press 'launch binder' badge and then when the temporary session comes up, run in a new cell %conda install -c conda-forge wordcloud (based on here). Restart the kernel and run your code.