2

I have just installed pypng library with sudo -E pip install pypng. I see this library in the list when I execute pip list (the version that I see there is 0.0.18).

When I start python (or ipython) session and execute

import pypng

I get

ImportError: No module named pypng
Roman
  • 124,451
  • 167
  • 349
  • 456

3 Answers3

7

According to docs on github you need to import png.

import png
png.from_array([[255, 0, 0, 255],
                [0, 255, 255, 0]], 'L').save("small_smiley.png")
vanadium23
  • 3,516
  • 15
  • 27
6

I think the module name is just png. Try the following:

import png
Istvan
  • 7,500
  • 9
  • 59
  • 109
1

Library name is not always the name of installed package. For the pypng it is just png, as noted in the documentation.

In case, if the documentation does not provide enough info, you could use pip show in order to list all installed files for specified package:

$ 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

As you can see, there is png.py file, which is being imported with import png.

awesoon
  • 32,469
  • 11
  • 74
  • 99