Menu

How to install a library Python : step by step guide

Follow us on Twitter 
Question, remark ? Contact us at contact@myengineeringtools.com


1. Python installation
2. Python library installation : step by step guide

Libraries are what makes Python cool : many developpers have already made so many functions ready to use. But how to install such a library to your local Python interpreter ? This step by step guide answers for a Windows environment.

1. Python installation

The pre-requisite is to install Python. The Python installer can be retrieved from the official Python website where the latest version, but also older ones, are available.

The only important point to remember is to select "add to path" when installing.

Python windows installation

Are you interested in AI ?
You can also check more resources about ChatGPT on MyEngineeringTools.com :

ChatGPT : All reply output formats ChatGPT can do

ChatGPT : 10 useful prompts for Engineers

2. Python library installation : step by step guide

Step 1 : verify that you can access Python in command line

Open a terminal : use the search function of Windows,

Windows search

then type command, then click on prompt command. A terminal window opens.

Windows access terminal

Then type python in minuscule.

If the following shows, then you're good. If not, you need to review the installation of Python.

Python terminal

Step 2 : localize the package you need with PyPi

Python has a kind of app store for the different libaries available. It is called PyPi. Just go 1st to PyPi to get the exact name of the package you wish to install.

For example, you want to install numpy. Go to pypi.org and type numpy in the search box.

Numpy on PyPi

It is available, you can download it thanks to the install tool given by Python, named pip.

Numpy in PyPi2

Step 3 : install the library with pip

Python has a tool to download and install the library from PyPi.

If you are still in the python prompt, exit by typing exit()

Exit Python shell

To install a new library that you just need to type the following command :

python -m pip install namelibrary

Replace namelibrary by what you want to install, in our case, numpy

python -m pip install numpy

Install numpy

Step 4 : enjoy your new library

The new library is now available.

Note that it can in some cases be more complicated due to some dependencies in between libraries although pip is able to manage some and install other packages that may be needed by the library you wish to use, but for the most common ones it should be sufficient.