README.rst 中的图像未显示在 pypi 中 [英] Image in README.rst not displaying in pypi

查看:69
本文介绍了README.rst 中的图像未显示在 pypi 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将包上传到 PyPI 时,我希望显示在我的 README.rst 文件中链接的图像.在我的自述文件中,我有:

I would like an image linked in my README.rst file to be displayed when I upload my package to PyPI. In my README I have:

.. image:: example-python.png
   :height: 100px
   :width: 200px
   :scale: 100 %
   :align: center

在 MANIFEST.in 中我有:

and in MANIFEST.in I have:

# Include the image file
include example-python.png

现在它没有显示在 testpypi 中.然而,它在 GitHub 上显示得很好.我做错了什么吗?

Right now it's not displaying in testpypi. It shows up just fine on GitHub, however. Am I doing something wrong?

推荐答案

.. image::example-python.png 中使用相对 URL,即浏览器期望图像在同一目录中作为包.我怀疑是否可以在 PyPI 上传图像.将其上传到某处并将 URL 更改为绝对 URL.我认为已经在 Github 上的图片没问题.

In .. image:: example-python.png you use relative URL, i.e. a browser expects the image in the same directory as the package. I doubt it's possible to upload an image at PyPI. Upload it somewhere and change the URL to be an absolute URL. An image already at Github is ok I think.

include 指令不起作用,因为它将图像包含在浏览器永远不会查找的源 (sdist) 存档中.

include directive in MANIFEST.in doesn't work because it includes the image into source (sdist) archive where browsers will never look it up.

这篇关于README.rst 中的图像未显示在 pypi 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆