mirror of
https://github.com/jbranchaud/til
synced 2026-03-04 06:58:45 +00:00
Add Check If Package Is Installed With Pip as a Python TIL
This commit is contained in:
@@ -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).
|
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:
|
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)
|
- [Access Instance Variables](python/access-instance-variables.md)
|
||||||
- [Break Debugger On First Line Of Program](python/break-debugger-on-first-line-of-program.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)
|
- [Create A Dummy DataFrame In Pandas](python/create-a-dummy-dataframe-in-pandas.md)
|
||||||
- [Dunder Methods](python/dunder-methods.md)
|
- [Dunder Methods](python/dunder-methods.md)
|
||||||
- [Install With PIP For Specific Interpreter](python/install-with-pip-for-specific-interpreter.md)
|
- [Install With PIP For Specific Interpreter](python/install-with-pip-for-specific-interpreter.md)
|
||||||
|
|||||||
50
python/check-if-package-is-installed-with-pip.md
Normal file
50
python/check-if-package-is-installed-with-pip.md
Normal file
@@ -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:
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user