Step-by-Step Guide- How to Install Pip in Command Prompt (CMD)
How to Install Pip in CMD
Installing pip, the package installer for Python, is a crucial step for any Python developer. It allows you to install and manage packages easily from the command line. In this article, we will guide you through the process of installing pip in the Command Prompt (CMD) on Windows.
1. Check if Python is Installed
Before installing pip, you need to ensure that Python is installed on your system. To check this, open the Command Prompt and type the following command:
“`
python –version
“`
If Python is installed, you will see the version number of Python. If you don’t have Python installed, you can download and install it from the official Python website (https://www.python.org/downloads/).
2. Set up Python’s PATH
Once Python is installed, you need to add it to your system’s PATH environment variable. This allows you to run Python commands from any command prompt.
To set up Python’s PATH, follow these steps:
1. Right-click on ‘This PC’ or ‘Computer’ on your desktop or in File Explorer.
2. Select ‘Properties’.
3. Click on ‘Advanced system settings’.
4. In the System Properties window, click on the ‘Environment Variables’ button.
5. In the Environment Variables window, scroll down and find the ‘Path’ variable.
6. Click on ‘Edit’.
7. If the ‘Path’ variable doesn’t exist, click on ‘New’ and add the following path:
“`
C:\Python39\;C:\Python39\Scripts\
“`
Replace ‘Python39’ with the version of Python you have installed.
8. Click ‘OK’ on all the open windows to save the changes.
3. Install pip
Now that Python’s PATH is set up, you can install pip using the following command:
“`
python -m ensurepip
“`
This command will install pip as a package, which can be imported and used in your Python scripts.
4. Verify the Installation
To verify that pip has been installed successfully, type the following command in the Command Prompt:
“`
pip –version
“`
You should see the version number of pip displayed. If you don’t see any output, pip may not have been installed correctly. In that case, try running the installation command again.
5. Install Python Packages
Now that you have pip installed, you can install Python packages using the following command:
“`
pip install package_name
“`
Replace ‘package_name’ with the name of the package you want to install. For example, to install the requests package, you would use:
“`
pip install requests
“`
Congratulations! You have successfully installed pip in the Command Prompt on Windows. Now you can easily manage Python packages and develop your Python applications.