jupyter / jupyter-drive

Google drive for jupyter notebooks
BSD 2-Clause "Simplified" License
418 stars 78 forks source link

Image files not rendered #125

Open singletS opened 9 years ago

singletS commented 9 years ago

python version: 3.4.3 |Anaconda 2.2.0 (64-bit)| IPython.__version__: 4.0.0

I'm getting the broken image icon in both of these cases:

Image files are in the same folder as the notebook.

Clicking the image filename in the tree browser brings up file picker. Clicked 'select' and restarted kernel/reload notebook, but same result (broken image icon).

SVG and JPG formats show same result.

All images render fine on the local filesytem.

Carreau commented 9 years ago

Well, the problem is the following, your (kernel, browser) and (content) are on different machines. Kernel and browser could even be also separated.

1 ) By choosing to store the content on Google drive, you make it inaccesible to the kernel, so IPython.display.Image("filename.jpg") will not work (partially due to 2 also).

2) The way google drive store images, and distribute through CDN, make <img src="filename.jpg">not work as the actual url is unknown to the user. You have to do a few query back and forth to google to know the URL, and for security reason, there is no simple way to do it for <img src="filename.jpg>".

So there is sadly not much we can do do fix that.

You can try, if you have a local version of image.jpg to force the embed=True when using IPython.display.Image("filename.jpg"). It will make the notebook bigger but might work.

singletS commented 9 years ago

Thanks for clarifying. I had (mistakenly) assumed since kernel could access the ipynb file, it could access other files through api magic...imagining the gdrive looked like a pseudo-file system to the kernel.

The motivation for using jupyter-drive was so students could save their work in ipynb format in their shared gdrive folders. I could then run their notebooks, add comments, etc. without download/uploading the related raw data files, images, etc. Maybe in the future :)

Thanks for the info and the suggestions!

Carreau commented 9 years ago

Well what you want to do is possible, if you mount google drive locally like a dropbox folder. Though the goal of this repo is to , at some point of the future, add real-time collaboration which require a different arrangement of things.

There is also a third way of doing things but which is not officially supported by google drive, and would have a bit of the advantages and drawbacks of both world.

The notebook has a lot of moving parts, so I completely understand it can be hard to figure out what will work when.

singletS commented 9 years ago

+1 for collaborative editing. My students currently use William's patched versions on SMC for this feature and they like it.

If only google drive would support "mounting" on linux machines like dropbox...drat.

Thanks again for your work. It's an exciting time for these tools.

chuong commented 8 years ago

To embed an image from your Google Drive into a notebook, add this line inside a Markdown cell:

<img src="http://drive.google.com/uc?export=view&id=SHARED_IMAGE_ID">

where SHARED_IMAGE_ID is the shared ID of the image. You have to share your image publicly and get this shared ID (quite long) from the shared link address. 

macraris-consulenza commented 6 years ago

Hello, Thank you so much for that

kngoledge commented 4 years ago

God bless you