Generating word cloud, doesnt display on the app

I am trying to display a wordcloud using the stylecloud module. Everything works well but the ide returns a warning message saying: “Starting a Matplotlib GUI outside of the main thread will likely fail.” Here is the sample code;

import stylecloud
from stop_words import get_stop_words
import streamlit as st
from import get_data

covid_data = get_data('data/bow.csv')

def app():


    stop_words = get_stop_words('english')

    concat_quotes = ' '.join(

        [i for i in covid_data.text_without_stopwords.astype(str)])

    t=stylecloud.gen_stylecloud(  # file_path='SJ-Speech.txt',


                                icon_name='fas fa-apple-alt',






Cant find a solution on line. How do you go about this?

Hi @Grivine-19, welcome to the Streamlit community!

Based on the following line in the code, it appears that this package only writes to a file:

If that’s truly the case, then the solution would be to use st.image() to read in the picture to the Streamlit app. You might also ask the maintainer of the package to add a Streamlit display method, it likely wouldn’t be a ton of effort for them.


Thank you so much @randyzwitch . This indeed is the solution to the challenge, saving as an image then using st.image function works in this case.

I however got an error when I deployed my app:
ImportError: cannot import name ‘makeMappingArray’ from ‘matplotlib.colors’ (/home/appuser/venv/lib/python3.7/site-packages/matplotlib/

According to Matplotlib, the function was deprecated since V3.34. See here. On my local machine, I had to copy-paste the function to the file for it to run. I got the function from this site.

In my code, I imported *matplotlib.pyplot as plt but never did I call the makeMappingArray function. Why does the streamlit app still need it to run both locally and on the streamlit sharing platform? How can it be corrected?