How do I add images to a PyPi readme (that works on GitHub)?

 ̄綄美尐妖づ 提交于 2020-11-26 11:01:26

问题


In my readme on GitHub I have several images that are present there in my project's source tree which I reference successfully with directives like

.. image:: ./doc/source/_static/figs/moon_probe.png

I would also like to have these images appear when this same readme is generated in PyPi.

How do I (a) ensure that images are present on PyPi for the readme to access and (b) formulate the .. image:: directive to access them?


回答1:


PyPI will not read your package distributions for the image. You have to use the image's external link, for example:

.. image::  https://raw.githubusercontent.com/greyli/flask-share/master/images/demo.png

Here I use the image hosted by GitHub, the real demo is on PyPI.

P.S. To get the image's raw link on GitHub, right-click the image and choose Open image in new tab.




回答2:


If you have your images on Github, navigate to the image then right click on download button and copy link address:

Then you can add it in your README.md file:

![](https://github.com/your_username/your_repository/raw/master/images/img2.png)

It should be rendered properly both on Github and PyPi.



来源:https://stackoverflow.com/questions/41983209/how-do-i-add-images-to-a-pypi-readme-that-works-on-github

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