pyversions
Get versions of imported modules in current session: pyversions.versions()
Designed particularly to work within a Jupyter or marimo notebook.
Call this function in a cell just after all modules/functions are imported.
This function uses Python inspect module to get the caller's global namespace; it should work, if not, pass globals() as a parameter.
Installation
pip install pyversions
Or
conda install -c duartexyz pyversions
Examples
>>> import pyversions
>>> vs = pyversions.versions()
>>> from pyversions import versions
>>> versions(); # semicolon to avoid printing information twice
More examples are in a marimo notebook in the docs directory. Run it in your browser, no installation needed:
| Notebook | molab | marimo.app |
|---|---|---|
| pyversions |
The notebook name links to a static preview with the outputs; the badges run the notebook in your browser with WebAssembly.
Or run it locally:
uvx marimo edit --sandbox docs/pyversions_notebook.py
Help
"""
Get versions of imported modules in current session: pyversions.versions()
Parameters
----------
glbs : globals(), optional (default=None)
Get all the imported modules from the passed globals() namespace.
show : bool, optional (default=True)
Whether to print information about environment and imported modules.
Returns
-------
info : list of strings
list of strings with information about the current environment and
imported modules.
Notes
-----
Designed particularly to work within a Jupyter or marimo notebook.
Call this function in a cell just after all modules/functions are imported.
This function uses Python inspect module to get the caller's global
namespace; it should work, if not, pass globals() as a parameter.
Based on https://stackoverflow.com/questions/40428931
Examples
--------
>>> import pyversions
>>> vs = pyversions.versions()
>>> from pyversions import versions
>>> versions(); # semicolon to avoid printing information twice
[In a marimo notebook](https://github.com/demotu/pyversions/blob/master/docs/pyversions_notebook.py)
Version history
---------------
'0.0.4' :
Use importlib.metadata (pkg_resources was removed from setuptools)
Find the distribution of modules whose import name is different
Fix the alignment of the columns and versions that are not strings
A module imported with different names is listed once
'0.0.3' :
Docs
"""
How to cite this work
Here is a suggestion to cite this GitHub repository:
Marcos Duarte. (2021). pyversions: A Python module to get versions of imported modules in current session (Version v0.0.3). Zenodo. http://doi.org/10.5281/zenodo.4599146
And a possible BibTeX entry:
@software{marcos_duarte_2021_4599146,
author = {Marcos Duarte},
title = {{pyversions: A Python module to get versions of
imported modules in current session}},
month = mar,
year = 2021,
publisher = {Zenodo},
version = {v0.0.3},
doi = {10.5281/zenodo.4599146},
url = {https://doi.org/10.5281/zenodo.4599146}
}
License
The non-software content of this project is licensed under a Creative Commons Attribution 4.0 International License, and the software code is licensed under the MIT license.
Metadata
Release files for pyversions 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyversions-0.0.4.tar.gz | 6.7 kB | With provenance | Details for pyversions-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyversions-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for pyversions-0.0.4-py3-none-any.whl |
Total release size: 13.2 kB
Release files / pyversions-0.0.4.tar.gz
| Download URL | pyversions-0.0.4.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f90efa6010d483a92156990e1f3ff95bc4f4e34bffcbb9b1b2aac9af1b87f82
|
|
BLAKE2b-256 checksum How to use checksums |
618d4af2a350e4062ded1e3c9a1f8e4fc85dc520b163cb47db2675665d62ddfd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / pyversions-0.0.4-py3-none-any.whl
| Download URL | pyversions-0.0.4-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e7f4354f36e9a69a1170a1bfc5e641e08614647f2d03afd187f6dbad916294b
|
|
BLAKE2b-256 checksum How to use checksums |
7aaee591b5a891ea10cd3c51b2985765f281ff39dbc39df840fbe4e2e6decd68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for pyversions 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pyversions-0.0.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.