From d084e0ffe01a26fa06a3fb1621a60ec01e60d1f9 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 19 Feb 2026 13:54:50 -0600 Subject: [PATCH] Add Check If Package Is Installed With Pip as a Python TIL --- README.md | 3 +- .../check-if-package-is-installed-with-pip.md | 50 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 python/check-if-package-is-installed-with-pip.md diff --git a/README.md b/README.md index 85e3ecd..59a2f54 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1740 TILs and counting..._ +_1741 TILs and counting..._ See some of the other learning resources I work on: @@ -1033,6 +1033,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Access Instance Variables](python/access-instance-variables.md) - [Break Debugger On First Line Of Program](python/break-debugger-on-first-line-of-program.md) +- [Check If Package Is Installed With Pip](python/check-if-package-is-installed-with-pip.md) - [Create A Dummy DataFrame In Pandas](python/create-a-dummy-dataframe-in-pandas.md) - [Dunder Methods](python/dunder-methods.md) - [Install With PIP For Specific Interpreter](python/install-with-pip-for-specific-interpreter.md) diff --git a/python/check-if-package-is-installed-with-pip.md b/python/check-if-package-is-installed-with-pip.md new file mode 100644 index 0000000..104eb63 --- /dev/null +++ b/python/check-if-package-is-installed-with-pip.md @@ -0,0 +1,50 @@ +# Check If Package Is Installed With Pip + +I recently installed PyTorch, but when I tried using it, I was getting an error +about `numpy` not being installed. I was kind of surprised by that because I +thought I would have already had that. + +I wanted to check, so I asked with `pip show`: + +```bash +❯ python3 -m pip show numpy +WARNING: Package(s) not found: numpy +``` + +I can even list everything that is installed with `pip` using `pip list` like +so: + +```bash +❯ python3 -m pip list +Package Version Build +------------------ --------- ----- +certifi 2026.1.4 +cffi 2.0.0 +charset-normalizer 3.4.4 +click 8.3.1 +commonmark 0.9.1 +cryptography 46.0.3 +docutils 0.22.4 +filelock 3.24.2 +fsspec 2026.2.0 +idna 3.11 +Jinja2 3.1.6 +... +``` + +I then installed `numpy` (`python3 -m pip install numpy`) and how I can use `pip +show` again to confirm that. + +```bash +❯ python3 -m pip show numpy +Name: numpy +Version: 2.4.2 +Summary: Fundamental package for array computing in Python +Home-page: https://numpy.org +Author: Travis E. Oliphant et al. +Author-email: +License-Expression: BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0 +Location: /Users/lastword/.local/share/mise/installs/python/3.12.12/lib/python3.12/site-packages +Requires: +Required-by: +```