Image in Jupyter Notebook ipynb doesn't show up in GitHub private repo but the same code works with public repo

女生的网名这么多〃 提交于 2021-01-21 04:41:05

问题


I have a Jupyter Notebook .ipynb file in my GitHub repository. It is supposed to show an image via the following markdown code:

![image](image.png)

The image does show up when the repository is public. However, when the repository is set to private, only the alternative caption "image" is visible and the image doesn't load. If I right-click on it and select "View Image", the image loads fine.

The issue also doesn't exist for .md Markdown files: the same line above works for public and private repos.

There is this answer which describes how to embed images into the .ipynb file, but that's not what I'm looking for. I want to display the .png file dynamically.


回答1:


As of 2015, Jupyter notebooks are rendered on GitHub using nbviewer. From this blog post they state:

Second, because of security concerns, some features available on nbviewer will not be available on GitHub. For example, GitHub will not render any dynamic output display that uses JavaScript, custom CSS, and most custom HTML embedded in Markdown or in outputs. When this is the case, and GitHub cannot fully render your notebooks, you will see an icon that allows you to view the full notebook on nbviewer.

An issue thread has some users saying that logging out/logging in will resolve the issue. Others say it is resolved over time. But there seems to be no recognized solution.




回答2:


I struggled a lot, than at last was able to fix it.

  1. Use "/" instead of "\" in image path

  1. If you are using width field for png image file than .png should be small, width="200" number should be in quotes, img should be closed like this ->img src="Image/neuron-1.png" width="300" />



回答3:


I have tested most of the comments; however, only the following works for me:

  1. Build the folder in the same repository with the image name.
  2. Create a file .gitkeep in the Image folder.
  3. Upload your images in this folder.
  4. Add address like: <img src='Image/name.PNG' />
  5. Note: building Image folder is necessary.


来源:https://stackoverflow.com/questions/55751415/image-in-jupyter-notebook-ipynb-doesnt-show-up-in-github-private-repo-but-the-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!