pip cheatsheet

Installing and managing packages of Python is a pain. Many popular Python packages are available for installation from Ubuntu repositories, but they are old versions.

The most convenient way to install, uninstall and manage Python packages is Pip.

  • pip is the usually the Python2 tool. pip3 is the Python3 tool. All the commands in this post will use pip, but they apply the same to pip3.

  • pip and pip3 can be installed from Ubuntu repositories:

$ sudo apt install python-pip python3-pip
  • To install a package from PyPI for all users:
$ sudo pip install foobar

This installs the package files to /usr/local/lib/python2.x/site-packages for pip and to /usr/local/lib/python3.x/site-packages for pip3.

  • To install a package from PyPI for only yourself:
$ pip install --user foobar

This installs the package files to ~/.local/lib/python2.x/site-packages.

  • To uninstall a package that was installed for all users:
$ sudo pip uninstall foobar
  • To uninstall a package that was installed only for you:
$ pip uninstall --user foobar
  • To upgrade an installed package:
$ pip install --upgrade foobar
  • To list all installed packages and their versions:
$ pip list
  • To search PyPI for a package by name:
$ pip search foobar
  • To list the installed file paths of a package:
$ pip show -f foobar
Advertisements

3 thoughts on “pip cheatsheet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.