Python is a popular programming language because of its powerful data structures, dynamic typing, dynamic binding, and many features to make it suitable for many software development requirements.
All this power comes from libraries and packages that speed up development by offering a mind-boggling range of pre-written functionality.
Table Of Content
- What Is pip?
- Install pip on Windows
- Confirm that Python is Installed
- Download pip with get-pip.py
- Verify pip Installation
- Add pip to Windows Environment Variables
- Configuring pip on Windows
- Upgrade pip on Windows
- Downgrade pip on Windows
- How to Uninstall pip on Windows
- Manage Python Packages With pip
This article will cover how to install pip on Windows and how you can use this simple utility to add power to your Python projects.
Let’s start with a simple introduction to pip.
What Is pip?
pip is a popular package management system that enables Python developers to install and manage third-party libraries that aren’t included in the standard Python distributions.
By default, pip fetches those packages and the dependencies from the Python Package Index (PyPI), a vast online repository of libraries and packages. As you might’ve guessed, PyPI is pip’s default source for packages and dependencies.
Install pip on Windows
Now that you understand pip’s importance in Python development, let’s discuss how to install pip on Windows.
Confirm that Python is Installed
Before proceeding to install pip on Windows, we need to ensure that Python is installed on the server.
For this, use the following commands in the command prompt:
> python --version
If you see an error message similar to “Python is not recognized as an internal or external command”, Python isn’t installed on the machine.
So, the first step is to download and install a recent version from https://www.python.org/downloads/windows/
Download the latest stable version for Windows and follow the wizard for installing Python on your machine. Once done, please verify the version using the command mentioned above.
Download pip with get-pip.py
Open the command prompt and navigate to the folder where Python is installed using the cd command. Then run the following command to download the get-pip.py file:
> curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
When the download finishes, start the install process by running the following command in the command prompt:
> python get-pip.py
Once the command finishes, pip is now successfully installed on Windows.
In case you get a “file not found” error, double-check the directory path to the file. You can use the dir command to view the entire contents of a directory. Please note that pip is installed by default with Python versions Python 2.7.9+ and Python 3.4+. pip also sets up virtualenv and pyvenv virtual environments during the installation process.
Verify pip Installation
If you need, you can verify that pip is installed correctly by running one of the following commands in the command prompt:
> pip -V
> pip --version
If pip is installed correctly, you’ll see a message indicating the version of PIP and its location on the local system.
Add pip to Windows Environment Variables
Even when pip has been successfully installed, you might get an error similar to “not on Path”. This could happen if you try to run pip from a location other than the installation folder.
However, chances are that you might not always be in the Python folder when you need to run pip. To avoid seeing this error, you need to add pip to Windows Environment Variables.
For this, follow the steps:
- Open the Control Panel, select System and Security, then select System.
- Go to the end of the list and select Advanced system settings:
- Click Environment Variables.
- In the System variables section, find and double-click the variable Path:
- Click New and add the path to the folder where you’ve installed pip:
- Click OK to confirm the addition.
Configuring pip on Windows
Pip is an essential utility for Python development, and developers often need to upgrade (or downgrade) it. Let’s start with the upgrade process.
Upgrade pip on Windows
Just like any other package, it’s important to make sure that pip is up-to-date so you can benefit from the newest features and security improvements. So, to upgrade pip, launch a command prompt window and type in this command:
> python -m pip install --upgrade pip
This command removes the current version and installs the newest version.
Downgrade pip on Windows
Occasionally, you might find it necessary to switch to an older pip version, mainly due to compatibility issues. You can “roll back” and easily install a specific version.
For this, open the command prompt, and enter this command. Remember to replace “18.0” with your preferred version number.
> python -m pip install pip==18.0
You should now have the desired version of the pip installed. It’s always a good idea to verify with the pip -V command after upgrading or downgrading pip versions.
How to Uninstall pip on Windows
If you want to uninstall pip, type the following command in your command prompt:
> pip uninstall pip
The system will ask for confirmation, and then pip will be uninstalled.
Manage Python Packages With pip
Now that pip has been properly set up and working on your Windows machine, you can easily install and manage Python packages.
You can install a Python package using the following command:
> pip install <package-name>
This command will install the latest version of the package. There are scenarios where you don’t need the latest version, mainly because of compatibility issues. So, if you’re looking to install a specific version of a package, use this alternative command:
> pip install <package-name==version>
You can view the information of a particular package using the following command:
> pip show <package-name>
This command shows essential package-related information, including the version, a brief description, and any dependencies required to run the package.
If you need to remove a package, pip offers the following command:
pip uninstall <package-name>
pip is the go-to package manager for Python, allowing the installation of almost all packages available at PyPI. In this article, we discussed how to install, uninstall and manage pip and Python packages.
Let us know if you have any questions about how to install pip on Windows.
Why do I need pip?
pip is the most widely-used package manager for Python. It is used to install, uninstall, and manage the entire package lineup for Python development workflow.
Should I install the latest pip version?
Ideally, yes. The latest pip version brings performance improvements and new features that enhance your Python development experience.