How to Install a Package in Python using PIP

In this short guide, I’ll show you how to install a package in Python using PIP. I will also demonstrate how to uninstall a package that is no longer needed.

If you’re using Windows, you’ll be able to install a Python package by opening the Windows Command Prompt, and then typing this command:


pip install package name


Note: 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 in the next section, I’ll cover the full steps to install a package in Python using PIP.

Here are the topics to be reviewed:

  • Simple example with the steps to install the pandas package
  • Uninstall a Python package
  • Tool that will allow you to easily install/uninstall Python packages

Steps to Install a Package in Python using PIP

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


Windows search


(2) Right click on the Command Prompt (i.e., the Windows Command Prompt, not the Python Command Prompt). Then, select Run as administrator.

By running the Command Prompt as an administrator, you’ll avoid any permission issues that you may come across when trying to install a package.


Command Prompt


(3) In the Command Prompt, type “cd\” as this command will ensure that your starting point has only the drive name:


Admin command prompt


(4) Press Enter. Now you’ll see the drive name of C:\>


Administrator command prompt


(5) Type cd followed by the path name where your Python Scripts folder is located (the Scripts folder should be located within the Python application folder, where you originally installed Python).

In my case, I installed Python 3.6 under the Program Files (x86). And the complete path where my Scripts folder is located is: C:\Program Files (x86)\Python36-32\Scripts


Python - scripts


Once you retrieved the Python Scripts path, type the following in the Command Prompt (do not forget to type the “cd” portion before the Python Scripts path):


Command prompt - Python scripts


(6) Press Enter, and you’ll see the following:


How to Install a Package in Python using PIP


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


pip install package name


Since in our case, we would like to install the pandas package, then you’ll need to type the following command in the Command Prompt:

pip install pandas 


How to Install a Package in Python using PIP


(8) Finally, press Enter, and you’ll notice that the package (here it’s pandas) will be installed:


pip install - Python


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

If no errors appear (after you press F5 to run the import command), then the package has been 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 set the Python Scripts path before you type this command):


pip uninstall package name


In our case, type: pip uninstall pandas and then press Enter:


How to Uninstall a Package in Python using PIP


Finally, type y and then press Enter in order to proceed with the removal of the package:


Uninstall a Package using PIP

Tool to install/uninstall a Python Package

Now I’ll share with you the code to install/uninstall Python packages using a simple tool I created.

Note that you’ll need to add Python to Windows path before you can start using the tool.

Here is the full Python code:


import os
import tkinter as tk

root= tk.Tk()

canvas1 = tk.Canvas(root, width = 300, height = 350, bg = 'gray90', relief = 'raised')

label1 = tk.Label(root, text='Type Package:', bg = 'gray90')
label1.config(font=('helvetica', 14))
canvas1.create_window(150, 80, window=label1)

entry1 = tk.Entry (root, width=27)
canvas1.create_window(150, 120, window=entry1)

def installPackage ():
    global installPythonPackage
    installPythonPackage = 'pip install ' + entry1.get()
    os.system('start cmd /k ' + installPythonPackage)

def uninstallPackage ():
    global uninstallPythonPackage
    uninstallPythonPackage = 'pip uninstall ' + entry1.get()
    os.system('start cmd /k ' + uninstallPythonPackage)

button1 = tk.Button(text='      Install Package    ', command=installPackage, bg='green', fg='white', font=('helvetica', 12, 'bold'))
canvas1.create_window(150, 180, window=button1)

button2 = tk.Button(text='   Uninstall Package  ', command=uninstallPackage, bg='coral3', fg='white', font=('helvetica', 12, 'bold'))
canvas1.create_window(150, 230, window=button2)



Simply run the code in Python and you should see the following screen:


How to Install a Package in Python using PIP


Type the package name that you’d like to install or uninstall. For example, type the package name pandas, and then click on the green button to install the package:


Install a Package in Python using PIP


That’s it! You should be able to enjoy the pandas package!