Skip to content

Commit 7e8a638

Browse files
committed
Fixed 403 Error from Wikimedia when reading image
1 parent 63882d0 commit 7e8a638

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

doc/python/imshow.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ In order to create a numerical array to be passed to `px.imshow`, you can use a
6161
```python
6262
import plotly.express as px
6363
from skimage import io
64-
img = io.imread('https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Crab_Nebula.jpg/240px-Crab_Nebula.jpg')
64+
from io import BytesIO
65+
import requests
66+
67+
url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/00/Crab_Nebula.jpg/240px-Crab_Nebula.jpg'
68+
headers = {"User-Agent": "Mozilla/5.0"}
69+
response = requests.get(url, headers=headers)
70+
img = io.imread(BytesIO(response.content))
6571
fig = px.imshow(img)
6672
fig.show()
6773
```

0 commit comments

Comments
 (0)