PIP is a standard package management system used to install and manage software packages written in Python. It stands for “preferred installer program” or “Pip Installs Packages.” The Python standard library comes with a collection of built-in functions and built-in packages.
PIP for Python is a utility to manage python package installations from the command line.
Data science packages like scikit-learn and statsmodel are NOT part of the Python standard library. They can be installed through pip, the standard package manager for Python, via the command line.
If you are using an older version of Python on Windows, you may need to install PIP. You can easily install PIP on Windows by downloading the installation package, opening the command line, and launching the installer.
Verify if PIP is Already Installed
Before you install PIP on Windows, check if PIP is already installed.
Type in the following command at the command prompt:
pip help
If PIP responds, then PIP is installed. Otherwise, there will be an error saying the program could not be found. PIP is automatically installed with Python 2.7.9+ onwards. PIP also comes with the virtualenv and pyvenv virtual environments.
Verify Python Installation
As a Python utility, PIP requires an active Python installation. In newer versions of Python and Python-enabled virtual environments, PIP is already installed, and you do not need to reinstall it.
Open the Command Prompt window and execute the below command
python
If this command is not unrecognized, you need to install Python before you can install PIP.
If the command is recognized, Python responds with its version and a list of commands.
Installing PIP On Windows
Before installing PIP, download the get-pip.py file from get-pip.py on pypa.io. When you open this link, you might be scared of the massive jumble of code that awaits you. Simply use your browser to save this page under its default name, which is get-pip.py
Download the file to the desired folder in Windows. You can save the file to any location, but remember the path so you can use it later.
Launch the Windows command prompt "As Administrator" and navigate to the downloaded location of the get-pip.py file and execute the following command
python get-pip.py
(In Linux, we can install pip via the command line by using the curl command (curl -O https://bootstrap.pypa.io/get-pip.py), which downloads the pip installation perl script.)
Check PIP Version
To check the current version of PIP, type the following command:
pip --version
Verify the PIP Installation
Once you’ve installed PIP, you can test whether the installation has been successful by typing the following:
pip help
If you receive an error, repeat the above installation process.
Upgrading PIP Version
New versions of PIP are released occasionally. These versions may improve the functionality or be obligatory for security purposes.
To upgrade PIP on Windows, enter the following in the command prompt:
python -m pip install --upgrade pip
This command first uninstalls the old version of PIP and then installs the most current version of PIP.
Downgrade PIP Version
This may be necessary if a new version of PIP starts performing undesirably.
If you want to downgrade PIP to a prior version, you can do so by specifying the version.
To downgrade PIP, enter:
python -m pip install pip==18.1
You should now see the version of PIP that you specified.
Now you have PIP up and running, you are ready to manage your Python packages.
Viewing a PIP List
Before you make any installs, it is a good idea to see what is already installed. You can use below command to display the Python packages in your current working environment in alphabetical order.
pip list
Installing a Package (NumPy) using PIP
Here is an example, to learn how you can install the NumPy package, which will install the other necessary dependencies.
pip install NumPy
Verify Package Installation
You can use the following command to verify package installation, as well as where the package is stored.
pip show numpy
Installing a Specific Package Version
pip will always install the latest version, so if you wish to install an older version of NumPy, you can specify it in the installation statement using the below command
pip install numpy==1.19.5
Upgrade a Package
If the package you are looking to use is already installed but simply out of date. You can upgrade the package with the below command.
pip install --upgrade numpy
Uninstall a Package
If you want to remove/uninstall a package, you can use the following command
pip uninstall numpy
Happy Learning!