Error message only when run locally"Please open the URL for reading and pass the result to Pillow"


I have an app with a matplotlib chart which has some images in it, these come from github URL, when running the deployed app on the cloud the code and images run and display correctly. When running the same code locally via conda I get the following error- “ValueError: Please open the URL for reading and pass the result to Pillow, e.g. with np.array(

This is the problem line

variation_icon = plt.imread(“”)

  • Streamlit version: 1.23.1
  • Python version: 3.10.11
  • Using Conda
  • OS version: windows 10
  • Browser version: edge and chrome

Requirements file

streamlit> 1.11.1
seaborn== 0.11.2


Additional information

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

1 Like

Thanks for reporting your issue, @mattchapman001!

Could you please try this and let me know if it would work?

import urllib.request
from PIL import Image
import numpy as np

url = ""
with urllib.request.urlopen(url) as url_obj:
    variation_icon = np.array(


The error you are getting is because Streamlit is trying to load the image from the GitHub URL using the plt.imread() function. However, the plt.imread() function only supports loading images from local files. To load images from a URL, you need to use the urllib.request.urlopen() function to open the URL and then pass the result to the function.

import streamlit as st
import urllib.request
from PIL import Image

def load_image_from_github(url):
  with urllib.request.urlopen(url) as response:
    image =
  return image

image = load_image_from_github("")


To resolve this issue, you can modify your code to download the image from the URL and then open it with Pillow’s function.

Try this and let me know If the issue has been fixed or not

Thanks for your help, issue resolved!

1 Like

Glad it worked!

Happy Streamlit-ing! :balloon:


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.