How to Install Python PIP on Windows, Mac, and Linux
Just as seen in any serious programming language, Python has supports for third-party libraries and frameworks that you can install to avoid reinventing the wheel with every new project that you are on. If you want to use them you can just find these Python libraries stored on a central repository Known as the Python Package Index (PyPI).
Downloading, installing, and managing these 3rd party packages by hand can be very frustrating and time-consuming. This is why most Python developers depend on a special tool known as PIP for Python to make everything much easier and much faster.
What Is PIP for Python?
PIP Which is the acronym for “PIP Installs Packages” or “Preferred Installer Program” is a command-line utility program that allows you to install, reinstall, or uninstall PyPI packages with a very simple and straightforward command: pip.
Is Python Correctly Installed?
Before you try to install PIP, you have to ensure that Python is properly installed on your system. On Windows, open up the Command Prompt by using the Windows key + X and selecting Command Prompt. On Mac, open the Terminal using Command + Space and searching for the terminal. On Linux, open the Terminal by using Ctrl + Alt + T. Linux shortcuts may vary by distribution.
Then type:
python --version
On Linux, Python 3.x users may need to use:
python3 --version
If you have got a version number (e.g. “Python 3.7.0”) then Python is ready to go.
If you get a “Python is not defined” message, then you will have to first install Python. That is beyond the scope of this article. The Python site has some detailed instructions for installation.
How to Install PIP on Windows
The following instructions should work on Windows 7-10:
- First download the get-pip.py installer script. If you’re on Python 3.2, you’ll need this version of get-pip.py instead. Either way, right-click on the link and select the Save As… and save it to any location that you want, such as your Downloads folder.
- Open the Command Prompt and go to the location of the get-pip.py file.
- Run the following command: python get-pip.py
How to Install PIP on Mac
Modern Mac PC come with Python and PIP already installed. However, this version of Python are mostly outdated and not the best choice for serious development with Python. It is highly recommended that you install a more recent version of Python and PIP.
If you want to make use of the native system Python installation but don’t have PIP available, you can install PIP by entering the following command in Terminal:
sudo easy_install pip
If you would rather install a more recent and up-to-date version of Python, then you can make use of Homebrew.
Installing Python with Homebrew is done by entering a single command:
brew install python
This will install on your system the latest version of Python, which should come pre-installed with PIP. If the installation is successful but PIP is unavailable in your PC, you may need to re-link Python by using the following Terminal command:
brew unlink python && brew link python
How to Install PIP on Linux
If your Linux distribution came pre-installed with Python, you should be able to install PIP using your system’s package manager. This is preferable since system-installed versions of Python do not work nicely with the get-pip.py script used on Windows and Mac.
Advanced Package Tool (Python 2.x)
sudo apt-get install python-pip
Advanced Package Tool (Python 3.x)
sudo apt-get install python3-pip
pacman Package Manager (Python 2.x)
sudo pacman -S python2-pip
pacman Package Manager (Python 3.x)
sudo pacman -S python-pip
Yum Package Manager (Python 2.x)
sudo yum upgrade python-setuptools sudo yum install python-pip python-wheel
Yum Package Manager (Python 3.x)
sudo yum install python3 python3-wheel
Dandified Yum (Python 2.x)
sudo dnf upgrade python-setuptools sudo dnf install python-pip python-wheel
Dandified Yum (Python 3.x)
sudo dnf install python3 python3-wheel
Zypper Package Manager (Python 2.x)
sudo zypper install python-pip python-setuptools python-wheel
Zypper Package Manager (Python 3.x)
sudo zypper install python3-pip python3-setuptools python3-wheel
How to Upgrade PIP for Python
While PIP itself does not bring up an update very often, it is still very important to stay on top of new versions because there might be important fixes to bugs, compatibility, and security holes in older versions. Fortunately for us,, upgrading PIP is very quick and easy.
On Windows:
python -m pip install -U pip
On Mac, Linux, or Raspberry Pi:
pip install -U pip
On certain versions of Linux and Raspberry Pi, you may need to use pip3 instead.
How to Install and Un-install Python Packages With PIP
Once PIP is ready, you can start installing packages immediately from PyPI:
pip install package-name
To completely get rid of a package:
pip uninstall package-name