mo.image() not working with local files
I'm trying to insert an image using mo.image(src="./imgs/mab_1.png") , it shows a broken image instead of the image. I've also tried the with open("logo.png", "rb") as file:
mo.image(src=file) approach - nothing turns up (Changed the string to point to my image. I'm not seeing any errors to work with. I've tried just opening the image directly and that works so i've not messed up the paths. Any suggestions?
4 Replies
@littlemermaid___ , thanks for providing the output of marimo env. I can reproduce your issue — mo.image() isn't working with local images for me either. Thanks for letting us know, looking into it.
Oops, spoke too soon. The file has to be opened in binary mode. This works for me:
The
img
has to be output in the last expression of the cell for it to show up. I can update the docs to be clearer about this. If you paste the above in a cell, does it work?For example:
Ah ok that makes sense! Thanks for the help
works a charm 👎
👍 rather!
Yep no problem! In the latest release you should also be able to pass a path to a local file