How to install Python packages with PIP

What is PIP?

PyPi Logo
PIP is the recommended tool for installing Python packages and modules written in Python.
PIP is straightforward to use, and it lets us manage and add new packages like Scipy, TensorFlow, OpenCV, Sympy, and more to our system or our virtual environment in a fast and easy way.

If you're a Windows user, PIP comes bundled with Python if you install it using the official installer from python.org. If you're a Linux user, you already have Python 3 and PIP installed in your system.

Install packages with PIP

PIP commands
Note: All the commands must be typed into a terminal or command promp, and they will only work as shown if you added Python to your PATH System Variable during the installation. If you didn't, look 'pip' is not recognized as an internal or external command.
To install a package with PIP, you only need to know the name with which it is listed in PyPi (The Python Package Index, with an online search engine that you can use to find packages) and write the following:
pip install <package-name>

Replacing "<package-name>" with the actual name of the package.
For example, if I want to install the library for symbolic math, Sympy, I would write the following in a command prompt:
pip install sympy

If you want to see the list of packages that you have installed with pip, you must introduce the following command in a command prompt:
pip list

And to update pip, you'll need to pass it as a parameter to the Python interpreter with the following command:
python -m pip install

Note for Linux users:

On most distros, there will be two versions of Python coexisting: Python 2.7, and some version of Python 3.x. To avoid conflicts, Python 3 tools, like the interpreter and pip, among others, have been renamed adding a "3" at the end. I.e., The interpreter of Python 3 will be referred to as python3 because the command python refers to the Python 2.7 interpreter. The same thing happens with PIP: pip is the package manager for Python 2.7, pip3 is the package manager for Python3.

So to install packages, you'll use the following command:
pip3 install <package-name>

To see the installed packages:
pip3 list
And to upgrade pip:
python3 -m pip install

Comments

Popular posts from this blog

How to install Spyder 3 on Windows without Anaconda

How to install PyQt5 and Qt Designer on Ubuntu

Hello World in Python 3