How to Install a Python Module on a Windows PC


In this article, we show how to install a Python module on a Windows PC or operating system.

So when you first go to Python's official site and download Python, you'll realize that there are no modules installed with Python other than the built-in ones like os and a few others that come with the installation. For most modules in Python, such as numpy and matplotlib, you must manually install them in order to be able to use them.

So how do we install a Python module on a windows PC?

This process is relatively easy.

You want to go to the task bar on the bottom of your screen and type in 'Command Prompt' and open up this program.

The way to install Python modules on a Windows PC is through the 'Command Prompt' software on a Windows PC.

What you have to do is find out where you installed Python and navigate to the Scripts directory of this Python software within this 'Command Prompt' program.

To have an idea where this is, you can open up your Python software and type in 2 lines, import os, and then os.getcwd(). This will return the currently working directory that this Python program is installed in.

The Scripts file will be in that current directory the majority of the time.

Go to the Scripts directory of your Python installation within the 'Command Prompt' software and then this is where you can install Python modules.

To change directories, you can either use the chdir() function and specify the full path to the Python Scripts directory or use the cd command to change directories relative to your current one.

If you actually go to this folder on your computer, you should see some applications, such as pip.exe, pip3.8.exe, and pip3.exe. These show that pip is installed within your computer and that you can use pip to install modules in Python.

So let's now install a module, such as matplotlib.

We do this through the following code shown below.

You should now see matplotlib being installed.

This is shown in the image below.

You can repeat this for all types of modules, including numpy, seaborn, and many others. Thus, you can use the rich data set of Python in order to accomplish many feats.

And this is how you can install Python modules on a Windows operating system.

Related Resources

How to Randomly Select From or Shuffle a List in Python

HTML Comment Box is loading comments...