Introduction to PIP and the Windows Ecosystem
The art of installing pip in Windows is a fundamental skillset for any aspiring developer, and PIP can be used to install, update, and uninstall software packages written in the Python programming language from the Python Package Index (PyPI). While the majority of installations of the programming language include the PIP manager by default, many users will find that, for a variety of reasons, they must install the pip manager for Windows manually. Explore our Python course syllabus to get started.
Overview of PIP (Preferred Installer Program)
If you are new to the world of Python programming, you will soon come to understand that while the native packages included with the programming language are impressive, the true power of the language comes from the vast array of packages available to you, from the data science powerhouses of Pandas and NumPy to the web frameworks of Django and Flask.
To gain access to this veritable treasure trove of programming, you will need a package manager, and for the world of Python, this manager is called PIP (Preferred Installer Program).
1. Checking if PIP is Already Installed
It is always important to check if you already have PIP installed in your Windows operating system. In recent versions of Python (3.4+), PIP is included by default.
How to Check if PIP is Already Installed
To check if you have PIP already installed in your system, you can follow the steps given below:
- Open the Command Prompt. Press the keys “Win + R” and type “cmd” and press Enter.
- Type the following command in the Command Prompt:
pip –version
- If you can see something like `pip 23.0.1 from … (python 3.11)`, you are good to go!
- If you can see ` ‘pip’ is not recognized as an internal or external command`, you have to install PIP. You can learn more with our Python tutorial for beginners.
Method 1: Installing PIP using the Python Installer
The best way to install PIP in Windows is to install it using the Python installer.
Steps for Clean Install:
- Download the latest version of the Python installer from python.org.
- Run the downloaded .exe file.
- CRITICAL STEP: Look at the bottom of the dialog box and make sure the box next to “Add Python to PATH” is checked.
- Select the Customize Installation option.
- Make sure the box next to “pip” is checked.
- Select Install.
Steps for Existing Install:
If you have already installed, but forgot to select the PIP checkbox:
- Go to the Control Panel, Programs and Features.
- Find the Python listing, right-click on it, and select the Change option.
- Select the Modify option.
- Make sure the box next to pip is checked, then select the Next and Install buttons.
Method 2: Installing PIP using get-pip.py
In case the above process fails, the official script can be used. This is the “Manual” way of installing pip on Windows.
Step-by-Step Instructions:
- Download the Script: Open your web browser and navigate to the website http://bootstrap.pypa.io/get-pip.py. Right-click on the webpage and select ‘Save As…’
- Open Command Prompt: Navigate to the location of the saved script.
- DOS
- cd Desktop
- Run the Script: Open the command prompt and type the following command:
- DOS
- python get-pip.py
- Verify: Once the script completes, run pip –version to ensure success.
Get hands-on exposure with our Python project ideas.
2. Fixing the “Not Recognized” Error (Adding to PATH)
It is quite common to receive the ‘pip’ is not recognized error after installing pip for Windows. This is because the PATH variable has not been set correctly.
How to add PIP to PATH manually:
- You first need to locate your Python Scripts folder. This is normally located here:
C:\Users\<YourUsername>\AppData\Local\Programs\Python\Python311\Scripts
- You need to copy this file path.
- You then need to right-click on This PC or My Computer and click Properties.
- Click Advanced system settings and then Environment Variables.
- You then need to scroll to System Variables and click Edit.
- You then need to click New and paste your Scripts folder path.
- You then need to click OK on all windows and restart your Command Prompt.
3. Essential PIP Commands for Beginners
After you have successfully installed pip in Windows, you can start using it. Here is a table that shows some of the essential commands that you will need to know as a beginner.
| Task | Command | Example |
| Install a Package | pip install <package> | pip install requests |
| Install Specific Version | pip install <package>==<version> | pip install flask==2.0.1 |
| Upgrade a Package | pip install –upgrade <package> | pip install –upgrade numpy |
| Uninstall a Package | pip uninstall <package> | pip uninstall scipy |
| List Installed Packages | pip list | pip list |
| Show Package Details | pip show <package> | pip show pandas |
| Check for Outdated | pip list –outdated | pip list –outdated |
4. Managing Dependencies with requirements.txt
In real-life programming projects, you will need to share your set of dependencies with other people. This is where PIP helps you.
Exporting your Environment:
DOS
pip freeze > requirements.txt
This will create a text file that has all the packages and their versions you have installed.
Installing from a file:
If you download a programming project that has a requirements.txt file, you can install all the packages in one command:
DOS
pip install -r requirements.txt
Enrich your skills through our Python interview questions and answers.
5. Using PIP with Virtual Environments
Another best practice that you should always keep in mind after you have successfully installed PIP in Windows is to avoid using the install command. This is because the install command can lead to version conflicts.
How to create a Virtual Environment:
- Open the command prompt and navigate to the folder that contains your project.
- Create the environment:
DOS
python -m venv myenv
- Activate the environment:
DOS
myenv\Scripts\activate
- Your command prompt will now have (myenv) at the beginning.
6. Troubleshooting Common PIP Issues
| Problem | Solution |
| Permission Denied | Run Command Prompt as Administrator. |
| Proxy Errors | Use the –proxy flag: pip install –proxy http://user:pass@server:port <package> |
| SSL Connection Error | Ensure your system clock is set correctly, or try pip install –trusted-host pypi.org <package> |
| PIP is Outdated | Run python -m pip install –upgrade pip |
Conclusion
Learning how to install pip in Windows is the gateway to the world of Python libraries. Whether you went the route of the automated installer or the manual get-pip.py script, having a package manager is not optional for modern development.
By following these steps to add PIP to your PATH and using virtual environments, you will keep your Windows development environment clean, efficient, and professional. Now you’re ready to install any of the 400,000+ packages available on PyPI and start making amazing applications. Enroll in our Python training in Chennai for a promising career.
