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

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.
- Use "/" instead of "\" in image path
- 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:
- Build the folder in the same repository with the image name.
- Create a file
.gitkeep
in the Image folder. - Upload your images in this folder.
- Add address like:
<img src='Image/name.PNG' />
- 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