Installing Python Packages with Pip and the PowerShell

In this article you will learn how to install Python packages using the pip package installer.

When you install Python on your computer, it comes with the standard library which is a collection of modules that allow you to do all sorts of useful things such as mathematical calculations, interacting with the operating system, building GUIs (Graphical User Interfaces) and much more.

However, it doesn’t stop there. There are thousands of third party libraries available for doing even more useful or obscure things with python. Things like handling pdf files, processing scientific data, working with audio and complex graphics for example.

To install these extra packages, Pip is the preferred package manager, which has been part of the standard installation of python from starting with Python 3.4, and is now included by default.

To use pip, you will need to be able to use a terminal or command prompt. This can be a bit scary for newcomers, so I’m going to walk you through it. These instructions are for Windows 10. On Mac or Linux, you need to find a program called terminal instead of PowerShell, but the rest is basically the same.

For example, let’s install matplotlib and do some simple graphing:

  • Go to the start menu
  • Begin typing powe... until you see the PowerShell application listed as below: Installing Python Packages with Pip and the PowerShell
  • Click on the item to open the PowerShell
  • Once the PowerShell is open, type pip install matplotlib and press enter Installing Python Packages with Pip and the PowerShell
  • That’s it! If all went well you will now be able to use matplotlib in your code, as in this example:
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')

Cool eh?

Please note these instructions assume you installed Python from , version 3.4 or above, and you selected the default options during installation. If there are problems then more yak shaving will be required than we will cover here, but do feel free to ask for help in the comments. Also, you may have already unknowingly installed matplotlib, in which case you will get a helpful message to that effect from PowerShell when you try to reinstall it.

In a recent article about using APIs with Python there was a section where we added some sound, and this required a third party package called playsound. If you didn’t know how to install packages before, go back now and see if you can get the full version of the program (complete with meow) working.

You should now hopefully be able to install whatever packages you want to extend Python’s functionality. here’s an article describing some of the more popular ones.

Happy coding, and if you get stuck write a comment and I’ll see if I can help.


You might also be interested to know that you can run python in the PowerShell simply by typing python then pressing Enter (assuming you installed Python using the standard version from which adds python to your system path..).

Also you can run files with python assuming the file is at the current location, or you can either navigate to the folder containing the file or type the full path.

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Join our mailing list

Join our mailing list to receive awesome articles about learning Python and Computer Science in a fun and accessible way, straight to your inbox.