Install a Package in Python using PIP

You can install a Python package by opening the Windows Command Prompt, and then typing this command:

pip install package_name

Note that the above method would only work if you already added Python to Windows path. Don’t worry if you don’t know what it means, as you’ll see the full steps to install a package in Python in the next section.

Steps to Install a Package in Python using PIP

(1) First, type Command Prompt in the Windows search box

(2) Next, open the Command Prompt, and you’ll see the following screen with your user name (to avoid any permission issues, you may consider to run the Command Prompt as an administrator):

C:\Users\Ron>

(3) Locate your Python Scripts path. The Scripts folder can be found within the Python application folder, where you originally installed Python.

You can find the Python Scripts path by following these steps:

  • Type “Python” in the Windows Search Bar
  • Right-click on the Python App, and then select “Open file location
  • Right-click again on the Python shortcut, and then select “Open file location
  • Double-click on the “Scripts” folder and then copy the path

Here is an example of a Python Scripts path:

C:\Users\Ron\AppData\Local\Programs\Python\Python311\Scripts

(4) In the Command Prompt, type cd, followed by space, and then your Python Scripts path:

C:\>cd C:\Users\Ron\AppData\Local\Programs\Python\Python311\Scripts

(5) Press Enter, and you’ll see something similar to the following:

C:\Users\Ron\AppData\Local\Programs\Python\Python311\Scripts>

(6) Now, type the PIP install command to install your Python package. The PIP install command has the following structure:

pip install package_name

For example, to install the Matplotlib package, type the following command in the Command Prompt:

pip install matplotlib 

C:\Users\Ron\AppData\Local\Programs\Python\Python311\Scripts>pip install matplotlib

(7) Finally, press Enter, and you’ll notice that the package (here it’s Matplotlib) would be installed:

Successfully installed matplotlib

You can quickly check if the package was successfully installed in Python, by opening the Python IDLE and then running “import matplotlib”

If no errors appear, then the package was successfully installed.

If you’re dealing with Anaconda, you may also want to check how to install a package using Anaconda.

Uninstall a Package using PIP

To uninstall a package using PIP, simply type the following command in the Command Prompt (do not forget to point to the Python Scripts path before you type this command):

pip uninstall package_name