What this command does and when you need it
Python3 -m pip install pypng downloads and installs the pypng library — a tool for reading and writing PNG image files — onto your computer so your Python programs can use it. The command breaks into three parts: python3 runs Python version 3, -m pip tells Python to use its built-in package manager, and install pypng names the library you want.
You need this command when you write a Python program that works with PNG images and that program includes a line like import png. Without pypng installed, that import fails and your program stops. The library is not built into Python by default, so you have to add it yourself.
This is different from downloading a program you click to open. You are installing code that other Python programs on your computer can use. Once installed, it stays on your system until you remove it.
Key Takeaways
- The command installs pypng in one line from your terminal or command prompt, and you only need to run it once per computer.
- You must have Python 3 and pip already installed before this command will work — most modern Python setups include both.
- The command downloads pypng from PyPI (Python Package Index), a public repository of libraries, so you need an internet connection.
- If the command fails, the most common causes are a typo in the command, Python 3 not being in your system path, or pip being out of date.
Opening your terminal or command prompt
The first step is to open the place where you type commands to your computer. On Windows, this is called Command Prompt or PowerShell. On Mac and Linux, it is called Terminal.
On Windows, press the Windows key, type cmd or powershell, and press Enter. On Mac, press Command + Space, type terminal, and press Enter. On Linux, the method depends on your desktop environment, but usually right-clicking the desktop or pressing Ctrl + Alt + T opens a terminal window.
Once the window opens, you should see a prompt — a line where you can type, usually ending with a $, #, or > symbol. This is where you will type the install command.
Typing and running the install command
At the prompt, type this exactly as shown: python3 -m pip install pypng
Check that you have typed it correctly: python3 (with the number 3, no space), a space, -m (a dash followed by the letter m), a space, pip, a space, install, a space, pypng. Then press Enter.
The command will start running. You will see text appear on the screen showing the read progress. This usually takes between 5 and 30 seconds depending on your internet speed. When it finishes, you will see a line that says Successfully installed pypng or similar, followed by the prompt returning.
What to do if you see an error
If you see an error message, the most common cause is that Python 3 is not found on your system path — the list of places your computer looks for programs. Try typing python -m pip install pypng instead (without the 3). Some systems use python as the command for Python 3.
If that also fails and the error says "python: command not found" or "python is not recognized", Python 3 is not installed on your computer. You will need to read and install Python from python.org first. Choose the version marked for your operating system (Windows, Mac, or Linux) and follow the installer.
If the error mentions pip itself — such as "No module named pip" — your Python installation is incomplete. Reinstalling Python usually fixes this. During installation, make sure the option to install pip is checked.
If the error says "Could not find a version that satisfies the requirement pypng", your internet connection may be down, or PyPI may be temporarily unavailable. Wait a few minutes and try the command again.
Checking that the installation worked
After you see the success message, you can verify that pypng is installed by typing python3 -c "import png; print('pypng is installed')" and pressing Enter. If pypng is installed correctly, you will see the message "pypng is installed" printed on the screen.
If instead you see an error like "ModuleNotFoundError: No module named 'png'", the installation did not complete. Try running the install command again, and if it fails a second time, check that your internet connection is working.
Using pypng in your Python programs
Once pypng is installed, you can use it in any Python program on your computer. At the top of your program file, add the line import png. You can then use pypng's functions to read PNG files, write PNG files, or modify image data.
The pypng library is now part of your Python environment. You do not need to run the install command again unless you uninstall it or move to a different computer. If you write a program that uses pypng and share it with someone else, they will need to run the install command on their own computer before the program will run.
Updating or removing pypng later
If a newer version of pypng is released and you want to update it, type python3 -m pip install --upgrade pypng. This downloads and installs the latest version while keeping your existing code working.
If you decide you no longer need pypng, type python3 -m pip uninstall pypng and press y when asked to confirm. This removes the library from your system. Any Python programs that try to import png will then fail until you reinstall it.
Frequently Asked Questions
Do I need to run this command every time I use a program that needs pypng?
No. You run the install command once, and pypng stays on your computer. Every Python program you write can then use it without running the command again. You only run it again if you uninstall pypng or want to update it to a newer version.
What is the difference between python and python3?
Python 3 is the current version of Python. Python 2 is an older version that is no longer supported. Most modern systems use python3 as the command. Some older systems may still have python point to Python 2, which is why specifying python3 ensures you get the right version.
Can I install pypng without using the command line?
Most Python development tools like Visual Studio Code or PyCharm have built-in ways to install packages without typing commands. Look for a package manager or terminal panel in your tool's menu. However, the command line method works on any computer with Python installed.
What if I use a different version of Python, like Python 2?
Python 2 is no longer maintained and should not be used for new projects. If you must use it, the command is python2 -m pip install pypng, but you should plan to upgrade to Python 3 as soon as possible.
Is pypng safe to install?
Yes. Pypng is a well-known open-source library hosted on PyPI, the official Python package repository. Millions of developers use it. The pip command downloads it from PyPI's find servers, so the installation is safe.