DEV Community

Cover image for pip commands You Should Know!!!
Koji (he/him)
Koji (he/him)

Posted on

pip commands You Should Know!!!

Photo by Hitesh Choudhary on Unsplash

If you don't use python's virtual env on your machine, you will need to use pip3 for python3 instead of pip.

List installed packages

$ pip list
Package            Version
------------------ ---------
appnope            0.1.0
argon2-cffi        20.1.0
attrs              19.3.0
backcall           0.2.0
bleach             3.1.5
certifi            2020.6.20
cffi               1.14.1
chardet            3.0.4
decorator          4.4.2

# Of course, you can use grep with |

$ pip list | grep six
six                1.15.0
Enter fullscreen mode Exit fullscreen mode

Output installed packages in requirements format

When you publish your python project to GitHub, publishing requirements.txt could be good since others can try your project without having module errors.

$ pip freeze
$ pip freeze > requirements.txt
Enter fullscreen mode Exit fullscreen mode

Show details of a package

$ pip show package_name

$ pip show six
Name: six
Version: 1.15.0
Summary: Python 2 and 3 compatibility utilities
Home-page: https://github.com/benjaminp/six
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /usr/local/lib/python3.8/site-packages
Requires:
Required-by: traitlets, python-dateutil, pyrsistent, packaging, jsonschema, bleach, argon2-cffi
Enter fullscreen mode Exit fullscreen mode

Install a package

$ pip install package_name
Enter fullscreen mode Exit fullscreen mode

Install a specific version

$ pip install tensorflow==1.14.0
Enter fullscreen mode Exit fullscreen mode

Update a package

$ pip install -U package_name
Enter fullscreen mode Exit fullscreen mode

Uninstall a package

$ pip uninstall -y package_name
Enter fullscreen mode Exit fullscreen mode

Install multiple packages

$ pip install package_name1 package_name2
Enter fullscreen mode Exit fullscreen mode

Install packages by requirements.txt

$ pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

Uninstall multiple packages

$ pip uninstall -y package_name1 package_name2
Enter fullscreen mode Exit fullscreen mode

Check packages dependencies

$ pip check
No broken requirements found.

# If your env has any dependency issues, you will see something here
Enter fullscreen mode Exit fullscreen mode

Discussion (0)