Creating Wordcloud from Jupyter Notebook


I have a program written in a Jupyter notebook that creates a wordcloud but I am having a hard time coverting it to work in Streamlit. I know I need to add the code import streamlit as st and then use st.pylpot() but I could not get the right syntax and figured it would be easier to share the raw text before entering the streamlit specific code.

Steps to reproduce

Code snippet:

import Wordcloud
from wordcloud import WordCloud
import matplotlib.pyplot as plt
from matplotlib import font_manager

# Create a WordCloud object
wordcloud = WordCloud(font_path= "C:\\windows\\Fonts\\simsun", background_color="white", max_words=5000, contour_width=3, contour_color='steelblue')

# Generate a word cloud
plt.figure(figsize = (15, 10))

plt.imshow(wordcloud, interpolation="bilinear")
# Visualize the word cloud

If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Have the worldcloud data display

Explain what you expect to happen when you run the code above.

I get at the moment which is obvious that there is no module called wordcloud.

Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.

Debug info

  • Streamlit version: 1.15.1
  • Python version: 3.9.15
  • Using Conda
  • OS version: Windows 10
  • Browser version: Chrome

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.


  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.

What is the problem with the syntax?

As I mentioned above if I run the code as is I get the error that the module Wordcloud doesn’t exist.

Wordcloud or wordcloud?


If the module Wordcloud does not exist, then do not import it.

So I downloaded the the module using pip install Wordcloud thinking that would solve the issue but it did not.

No, not importing Wordcloud will solve it.

OK I will try thanks

I was also trying to use WordCloud but it doesn’t seem to be installed on streamlit. Is that correct? What is the way around it?

Actually just realised that you need to add all your imports to requirement.txt file so that the installs are available on Streamlit Cloud