from IPython.display import Image
IPython's Image display object takes three kinds of arguments
open(filename).read()
with open("Graphs/graph.png") as f:
data = f.read()
Image(data=data)
The second model is to load an image from a filename. This is functionally the same as above, but IPython does the reading from the file:
Image(filename="Graphs/graph.png")
The third form is passing URLs. Absolute URLs can be used, but relative URLs will be served relative to the notebook's own directory:
Image(url="Graphs/graph.png")
This looks the same as above, but instead of embedding the image data in the notebook document itself, it just links to the image:
Image(url="Graphs/graph.png")._repr_html_()
Where this can get confusing is if you don't tell IPython which one of these you are specifying, and you just pass the one argument positionally:
Image("Graphs/graph.png")
IPython tries to guess what you mean in this case:
That #3 is the source of the most confusion. If you pass it a filename that doesn't exist, you will get a broken image:
Image("/Graphs/graph.png")
Image("/Graphs/graph.png")._repr_png_()
which is obviously not valid PNG data.
Note that URLs to files must be relative. Absolute URLs will generally be wrong:
Image(url="/Graphs/graph.png")