0

Somewhat new to Python. Trying out PyPNG (need to write some simple PNG files). Using the code (almost) exactly as in the examples in the documentation.

import png

def main():
  f = open('ramp.png', 'wb')      # binary mode is important
  w = png.Writer(255, 1, greyscale=True)

  w.write(f, [range(256)])

  f.close()

if __name__ == "__main__":
  main()

Tried running exactly as written in the documentation (without the main() additions).

When I run, I get the error:

AttributeError: 'module' object has no attribute 'Writer'

Google and SO offer nothing. Please help?

kindall
  • 178,883
  • 35
  • 278
  • 309
  • 2
    After `import png` in your program, add `print(png.__file__)` and edit to include the result. Probably the module is being shadowed by another program (say, if you called your own program `png.py`.) – DSM Mar 08 '16 at 04:05
  • That... is exactly what I did. THANK YOU. – Parker Harris Emerson Mar 08 '16 at 04:12

0 Answers0