loading...
Cover image for pip commands You Should Know!!!

pip commands You Should Know!!!

kojikanao profile image Koji (he/him) ・2 min read

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

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

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

Install a package

$ pip install package_name

Install a specific version

$ pip install tensorflow==1.14.0

Update a package

$ pip install -U package_name

Uninstall a package

$ pip uninstall -y package_name

Install multiple packages

$ pip install package_name1 package_name2

Install packages by requirements.txt

$ pip install -r requirements.txt

Uninstall multiple packages

$ pip uninstall -y package_name1 package_name2

Check packages dependencies

$ pip check
No broken requirements found.

# If your env has any dependency issues, you will see something here

Posted on by:

kojikanao profile

Koji (he/him)

@kojikanao

Looking for opportunities! Software Engineer in NYC/Research Resident@NYU-ITP18-19 Mostly I work with reactjs and sometimes python. code to do something weird/useless/helpful Japanese

Discussion

pic
Editor guide