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?
Just add an <img> tag to your README.md with relative src to your repository.
Drag and drop the image into the Comment field. The image will start uploading to Github servers. 4) Save the markdown file. And you'll see the image placed inline in the markdown file.
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
If you are using Markdown description, use this:
![](https://raw.githubusercontent.com/greyli/flask-share/master/images/demo.png)
Be sure to replace the URL in the above examples with your image URL, 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 Copy image address.
Go to the image address in the Github repository. The path shown will be like this: https://github.com/tensorbored/kds/blob/master/docs/_static/readme_lift.png Change the blob term in the image address to raw https://github.com/tensorbored/kds/raw/master/docs/_static/readme_lift.png
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.
Setting ?raw=True
at the end of GitHub image link seems to work.
example:
![Sample image](https://github.com/usename/reponame/blob/master/sample.png?raw=True)
I had found this somewhere on the internet previously, but couldn't find it now. I'll credit the original author when I find it again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With