IPython magic function to print date/time stamps and various system information.
Project description
watermark
An IPython magic extension for printing date and time stamps, version numbers, and hardware information.
Sections
Examples
[top]
Using watermark in Jupyter notebooks and IPython sessions
More examples can be found in this Jupyter notebook.
Using watermark as a module
from watermark import watermark
print(watermark())
Last updated: 2022-09-13T16:28:56.177487-05:00
Python implementation: CPython
Python version : 3.9.13
IPython version : 8.4.0
Compiler : Clang 13.0.1
OS : Darwin
Release : 21.6.0
Machine : arm64
Processor : arm
CPU cores : 10
Architecture: 64bit
print(watermark(packages="numpy,scipy"))
numpy: 1.23.2
scipy: 1.9.1
See help(watermark) for more options.
Installation and updating
[top]
The watermark line magic can be installed by executing
pip install watermark
Alternatively, you can install the latest development version directly from GitHub via
pip install -e git+https://github.com/rasbt/watermark#egg=watermark
Note:
To remove an old watermark installation (installed via the deprecated %install_ext magic extension), simply delete it from the .ipython/extensions/ directory, which is typically located in a user's home directory.
Usage
[top]
After successful installation, the watermark magic extension can be loaded via:
%load_ext watermark
To get an overview of all available commands, type:
%watermark?
%watermark [-a AUTHOR] [-gu GITHUB_USERNAME] [-e EMAIL] [-ws WEBSITE]
[-d] [-n] [-t] [-i] [-z] [-u] [-c CUSTOM_TIME] [-v]
[-p PACKAGES] [-co] [-h] [-m] [-g] [-r] [-b] [-w] [-iv]
IPython magic function to print date/time stamps
and various system information.
optional arguments:
-a AUTHOR, --author AUTHOR
prints author name
-gu GITHUB_USERNAME, --github_username GITHUB_USERNAME
prints author github username
-e EMAIL, --email EMAIL
prints author email
-ws WEBSITE, --website WEBSITE
prints author or project website
-d, --date prints current date as YYYY-mm-dd
-n, --datename prints date with abbrv. day and month names
-t, --time prints current time as HH-MM-SS
-i, --iso8601 prints the combined date and time including the time
zone in the ISO 8601 standard with UTC offset
-z, --timezone appends the local time zone
-u, --updated appends a string "Last updated: "
-c CUSTOM_TIME, --custom_time CUSTOM_TIME
prints a valid strftime() string
-v, --python prints Python and IPython version
-p PACKAGES, --packages PACKAGES
prints versions of specified Python modules and
packages
-co, --conda prints name of current conda environment
-h, --hostname prints the host name
-m, --machine prints system and machine info
-g, --githash prints current Git commit hash
-r, --gitrepo prints current Git remote address
-b, --gitbranch prints current Git branch
-w, --watermark prints the current version of watermark
-iv, --iversions prints the name/version of all imported modules
--gpu prints GPU information (currently limited to NVIDIA
GPUs), if available
-je, --jupyter_env prints the current Jupyter environment (e.g., Colab,
VS Code)
--python_installation
include information about how Python was installed
--check_latest check if the latest packages are installed
Development guidelines
[top]
In line with NEP 29, this project supports:
- All minor versions of Python released 42 months prior to the project, and at minimum the two latest minor versions.
Changelog
[top]
v. 2.6.0 (TBA)
- Adds a new
--check_jupyterflag to report on which notebook environment is used (e.g., Colab, Jupyter Notebook, Jupyter Lab, VSCode). (#102, via contribution by Mariam Zakaria) - Adds a new
--check_latestflag to check whether newer package versions are available. (#102, via contribution by Mariam Zakaria) - Adds a new
--python_installationflag to provide information about how Python was installed. (#102, via contribution by Mariam Zakaria)
v. 2.5.1 (Dec 14, 2025)
--iversionpackages are now sorted alphabetically. (#102, via contribution by Vijay Lulla)- Extra args to allow printing
-d(current date) and-t(current time) information without needing to use the-u(updated) flag. (#99, via contribution by Daniel Kleine)
v. 2.5.0 (Sep 20, 2024)
- Can now capture imports retrospectively via
-ivmore reliably. (#94, via contribution by Martin Perier)
For example,
from sympy import solve
%load_ext watermark
%watermark -iv
Correctly prints sympy: 1.11.1
v. 2.4.3 (May 23, 2023)
- Make
py3nvmlinstallation for GPU info optional. (#92, via contribution by Ben Greiner)
v. 2.4.1 and v 2.4.2 (May 23, 2023)
- PyPI and Conda-Forge packaging fixes.
v. 2.4.0 (May 23, 2023)
- Adds a new
--gpuflag to print out GPU information (currently limited to NVIDIA devices) (#90, via contribution by 907Resident)
v. 2.3.1 (May 27, 2022)
- Upper limit on importlib-metadata caused trouble installing on Python 3.7. Instead pin to minimum version with Python 3.8 functionality according to https://github.com/python/importlib_metadata#compatibility (#86, via contribution by James Myatt)
v. 2.3.0 (January 3, 2022)
- Added the following arguments:
--github_username- for prints author github username,--email- for prints author email,--website- for prints author or project website. (#82, via contribution by joschkazj) - Added a
--condaoption to print the name of the current conda environment. (#79, via contribution by Alexander Krasnikov) - It is now possible to inject globals when used outside IPython (#80, via contribution by Hugo Lapré). For example, version numbers of imported packages can now be obtained as follows:
import numpy
import watermark.watermark as watermark
watermark(iversions=True, globals_=globals())
v. 2.2.0 (February 17, 2021)
- Refactoring such that a
watermark()function now also works outside IPython and Jupyter. Now, the magic%watermarkcallswatermark(). Calling%watermarkvia IPython and Juypter still works as usual. However, in addition thewatermark()function can be used within regular Python for unit testing purposes etc. (#46, via contribution by Tymoteusz Wołodźko)
v. 2.1.0 (November 23, 2020)
- Adopt NEP 29 and require Python version 3.7 or newer. (#63, via contribution by James Myatt)
- Add Python 3.8 and 3.9 to Travis CI builds. (#63, via contribution by James Myatt)
- Fix: Allow setup.py to run without install_requires already installed (#67, via contribution by James Myatt)
- Major refactoring to improve code readability (#64 and 65, via contribution by Bahram Aghaei)
- Use importlib and importlib.metadata to determine package version numbers. (#66, via contribution by James Myatt)
v. 2.0.2 (November 19, 2019)
- Support
VERSIONattributes, in addition to__version__attributes.
v. 2.0.1 (October 04, 2019)
- Fix
'sklearn'vs.'scikit-learn'import compatibility.
v. 2.0.0 (October 04, 2019)
- Now uses
pkg_resourcesas the default method for getting version numbers. - Fixes a whitespace bug when printing the timezone.
v. 1.8.2 (July 28, 2019)
- When no Python library was imported and the
--iversionis used, print an empty string instead of raising an error.
v. 1.8.1 (January 26, 2019)
- Fixes string alignment issues when the
-iv/--iversionflag is used.
v. 1.8.0 (January 02, 2019)
- The
-iv/--iversionflag now also shows package versions that were imported asfrom X import Yandimport X.Y as Y. For example,
import scipy as sp
from sklearn import metrics
import numpy.linalg as linalg
%watermark --iversions
will return
scipy 1.1.0
sklearn 0.20.1
numpy 1.15.4
v. 1.7.0 (October 13, 2018)
(Via contribution by James Myatt)
- Shows "not installed" for version of packages/modules that cannot be imported.
- Shows "unknown" for version of packages/modules when version attribute cannot be found.
- Add Python 3.6 and 3.7 to Travis CI builds.
- Add classifiers to setuptools configuration.
v. 1.6.1 (June 10, 2018)
- Now also includes the LICENSE file in the Python Wheels distribution
v. 1.6.0 (January18, 2018)
- Adds a new
-b/--gitbranchparameter that prints the current Git branch.
v. 1.5.0 (August 27, 2017)
- Adds a new
-iv/--iversionsparameter that prints the package names and version numbers of all packages that were previously imported in the current Python session. (Via contribution by Aziz Alto)
v. 1.4.0 (April 18, 2017)
- Adds a new
-r/--gitrepoparameter that returns the URL of Git remote name "origin". (Via contribution by Lucy Park)
v. 1.3.4 (October 15, 2016)
- Allow fetching scikit-learn's version number via
-p scikit-learnin addition of-p sklearn(the former is deprecated and will not be supported in watermark > 1.7).
v. 1.3.3 (September 1, 2016)
- Includes LICENSE in MANIFEST.in for packaging
v. 1.3.2 (August 16, 2016)
- Fixes an issue where the wrong package info was obtained when using the system level Jupyter within a virtualenv environment. (Via contribrution by Michael Bell)
- Adds a new
-i/--iso8601parameter that returns the current date-time string in ISO 8601 format with offset to UTC. For instance:2016-08-16T18:03:42-04:00. Current caveat: Python < 3.2 requires external libraries for for computing the timezone offset, thus, Python < 3.2 will currently only print2016-08-16T18:03:42 - Adds offsets to UTC to the default date-time string for Python >= 3.2
v. 1.3.1 (June 6, 2016)
- Fixes an issue that caused problems importing watermark using Python 2.x
v. 1.3.0 (May 21, 2016)
- Removed the deprecated the %install_ext magic so that watermark can now be installed as a regular python package via
pip(Via contribution by Peter Bull)
v. 1.2.3 (January 29, 2016)
- Changed date format to the unambiguous ISO-8601 format
- Ditched the deprecated %install_ext function and made watermark a proper Python package
- Released the new version under a more permissive newBSD license
v. 1.2.2 (June 17, 2015)
- Changed the default date-format of
-d,--dateto MM/DD/YYYY, the format DD/MM/YYYY can be used via the shortcut-e,--eurodate.
v. 1.2.1 (March 3, 2015)
- Small bugfix to allow custom time string formatting.
v. 1.2.0 (October 1, 2014)
--watermarkcommand added to print the current version of watermark.- Print author name on a separate line
- Fixed bug that day takes the same value as the minute if the
-nflag is used.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file watermark-2.6.0.tar.gz.
File metadata
- Download URL: watermark-2.6.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee4fadccbebe855a23ae48bb8a20c1da6ddb9d81f53b6c30c77de767c7161930
|
|
| MD5 |
fd6ffe85f36b807a18bcbe1234595168
|
|
| BLAKE2b-256 |
d2f4a1e4c497be237e19eb2da3417e7e48973e0f59413d262d1440e769fe0e2b
|
File details
Details for the file watermark-2.6.0-py3-none-any.whl.
File metadata
- Download URL: watermark-2.6.0-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c925daf1c3f7db9aa5fe25aff3a5fd07df0619ff0bd271bf809bfd6b0c628332
|
|
| MD5 |
086347cc0c4cf8c11b3867328c53691e
|
|
| BLAKE2b-256 |
a0bd5e98be0ff12e580985ad647f2c33be97abde81fccbfd1655fc7536043c0f
|