34

I'm kind of new to installing modules in python. I looked at this, http://pythonhosted.org/pypng/png.html#png.Reader.asRGB8 But there is no download link.

It says "installation is trivial" but trivial means of little value or importance. So I google "python png module download" but all the links are for 'pypng' It says to use import png not import pypng.

So then I google how to install python modules, And I came across easy install. But easy install has its own installation also.

Is my best bet to use c# or c++ instead where it's much easier to download libraries?

Xmodder Xpos
  • 341
  • 1
  • 3
  • 3
  • [*"Just use `python setup.py install` or just copy the `code/png.py` file"*](http://pythonhosted.org/pypng/ca.html) - have you tried either of these methods? What happened? If you don't know where to get the files from, see https://github.com/drj11/pypng – jonrsharpe Jun 30 '15 at 15:58
  • See [this answer](http://stackoverflow.com/questions/31130126/importerror-no-module-named-foxhound-utils-vis/31132573#31132573) on how to install a python module. And this is the [download link for pypng](https://github.com/drj11/pypng/archive/master.zip). – doru Jun 30 '15 at 15:59
  • I can't get it to install either. I am in the right directory. Getting a syntax error like the file does now exist. I would just copy the file mention but you did not say where to. – Gary Carlyle Cook Mar 20 '17 at 17:25
  • I got it. Thanks. I was doing it through the Python CL and should have done it with the Windows CMD. – Gary Carlyle Cook Mar 20 '17 at 17:42

4 Answers4

56

Try to print in command line/Terminal:

pip install pypng

and then import in your code as

import png

These are the same packages but it should be installed and be imported under different names

Andersson
  • 51,635
  • 17
  • 77
  • 129
  • 3
    Thought that would be it. :P Typically the package name for a python library will be "pysomething", but the python namespace it puts its functions in will be just `something`. Package names have to be unique against other png libraries for other languages, but python namespaces are already specific to python code. – Peter Cordes Jun 30 '15 at 16:01
  • I finally got pypng installed, But theres no examples on the documentation, How would I get the RGB8 values of each pixel individually? I don't really care about speed or preformance... – Xmodder Xpos Jun 30 '15 at 17:13
  • I guess this is another story:) You should try to find something here https://pythonhosted.org/pypng/ex.html and if not successful create new question – Andersson Jun 30 '15 at 18:25
  • I'm using Python 3.8 and I can't import the png package. Even after a successful installation I keep receiving a this exception: `ModuleNotFoundError: No module named 'png'` – Milky Nov 16 '20 at 23:22
5

I encountered several errors while trying to install pypng. I solved it with running it as ROOT:

$ sudo pip install pypng
Melchia
  • 22,578
  • 22
  • 103
  • 117
3

On Ubuntu 20.04 this works:

  1. install pip

    sudo apt install python3-pip

  2. install png

    sudo pip3 install pypng

  3. import library in code

    import png

Niels Tolstrup
  • 457
  • 4
  • 12
1

Here is another option, for conda users:

conda install -c eaton-lab pypng
user2821
  • 1,568
  • 2
  • 12
  • 16