watermark
raw JSON → 2.6.0 verified Fri May 01 auth: no python
An IPython magic function to print date/time stamps, system information (e.g., Python version, OS, hardware), GPU details, and package versions. Current version: 2.6.0. Release cadence: irregular, ~1-2 releases per year.
pip install watermark Common errors
error ModuleNotFoundError: No module named 'watermark' ↓
cause watermark is not installed.
fix
Install with: pip install watermark
error UsageError: %watermark is not a valid IPython magic function. ↓
cause The watermark magic is not loaded; you may have forgotten to load the extension or run in an environment without IPython.
fix
In IPython/Jupyter, run: %load_ext watermark
error KeyError: 'pkg_resources' ↓
cause setuptools/pkg_resources is missing in the environment.
fix
Install setuptools: pip install setuptools
error TypeError: watermark() takes 0 positional arguments but 1 was given ↓
cause Attempting to call the magic function as a Python function with arguments incorrectly.
fix
Use the
watermark() function from the module with appropriate keyword arguments, e.g., watermark(packages='numpy'). Warnings
breaking The `watermark()` function (non-magic) was added in v2.2.0. Importing `watermark` from the package returns the function, not the magic. The magic %watermark still works in IPython. ↓
fix Use `from watermark import watermark` and call `watermark()` in scripts; for IPython magic, use `%watermark` as before.
deprecated The `--gpu` flag requires `py3nvml` (optional). If not installed, watermark will ignore the flag without error. ↓
fix Install py3nvml if GPU information is needed: `pip install py3nvml`.
gotcha The `-p` flag expects package names, not import names. For example, use `-p scikit-learn`, not `-p sklearn`. ↓
fix Use the correct distribution name (e.g., scikit-learn) rather than the import module name.
gotcha Library version detection uses `pkg_resources` or `importlib.metadata`. If a package is installed in development mode (pip install -e), the version may be `0.0.0` or missing. ↓
fix Ensure packages are properly installed; avoid editable installs for version detection.
Imports
- watermark
from watermark import watermark
Quickstart
# In a Jupyter/IPython notebook cell:
%watermark -v -m -p numpy,scipy --gpu
# Or in a regular Python script:
from watermark import watermark
print(watermark())