我刚刚用pypng安装了sudo -E pip install pypng库。当我执行pip list (我看到的版本是0.0.18)时,我会在列表中看到这个库。
启动python (或ipython)会话并执行
import pypng我得到了
ImportError: No module named pypng发布于 2016-04-04 08:37:52
根据github上的docs,您需要导入png。
import png
png.from_array([[255, 0, 0, 255],
[0, 255, 255, 0]], 'L').save("small_smiley.png")发布于 2016-04-04 08:37:51
我认为模块名只是png。尝试以下几点:
import png发布于 2016-04-04 08:41:35
库名并不总是已安装包的名称。对于pypng来说,它只是png,就像文件中注意到一样。
如果文档没有提供足够的信息,可以使用pip show列出指定包的所有已安装文件:
$ python -m pip show -f pypng
Metadata-Version: 2.0
Name: pypng
Version: 0.0.18
Summary: Pure Python PNG image encoder/decoder
Home-page: https://github.com/drj11/pypng
Author: David Jones
Author-email: drj@pobox.com
License: UNKNOWN
Location: /usr/lib/python3.5/site-packages
Requires:
Files:
__pycache__/png.cpython-35.pyc
png.py
pypng-0.0.18.dist-info/DESCRIPTION.rst
pypng-0.0.18.dist-info/INSTALLER
pypng-0.0.18.dist-info/METADATA
pypng-0.0.18.dist-info/RECORD
pypng-0.0.18.dist-info/WHEEL
pypng-0.0.18.dist-info/metadata.json
pypng-0.0.18.dist-info/top_level.txt如您所见,有png.py文件,它是用import png导入的。
https://stackoverflow.com/questions/36397885
复制相似问题