How to attach an image in Jupyter Notebook without keeping the file in the same directory?

I'm trying to use Jupyter Notebook in VS Code (but tested the same thing in Jupyter on browser, and didn't work as well).

If I put the image file in the same directory of the ipynb file, I can drag and drop using the code below, and it works:


But if I move the image file to other directory, or delete it, the image doesn't appear anymore.

I tried to use:


as I saw in others examples (which was working fine), but when I try the same, it doesn't work.

I want to attach the image in ipynb file and make it independent of the source image file, as I can do in a MS Word file, for example.


  • First try copying the image and pasting it, run the cell and see if it works. If it works, it will work every time. After pasting the picture the code looks like this:-


    Next, Run the cell and it will be inserted.

    Pic of pasting picture:-

    Pic of picture inserted:-

    Picture added

    Pasting picture