Is there a sessionInfo() equivalent in Python?

Viewed 4989

Normally I use R, and often when wanting to make things reproduicible I use sessionInfo(). The reason for this is that I like to let people know what version of everything I am using and what packages I have installed/loaded and what OS I am on etc, so that its quite clear.

sessionInfo returns the version of R, the processor type (e.g. 32/64 bit x86), the operating system, the locale details, and which packages have been loaded.

I am new to python and wondered if there is an equivalent for Python? I'm hoping to use it in an iPython Notebook...

3 Answers

Conda related answer

As I regularly install and run jupyter-notebooks with conda (instead of pip), I will leave this here in case it is helpful to someone else. At the end of my notebooks I usually have a cell with:

!conda list

# packages in environment at /path/to/my/conda_env:
#
# Name                    Version                   Build  Channel
_r-mutex                  1.0.1               anacondar_1    conda-forge
appnope                   0.1.2            py39h6e9494a_1    conda-forge
argon2-cffi               20.1.0           py39hcbf5805_2    conda-forge
async_generator           1.10                       py_0    conda-forge
attrs                     21.2.0             pyhd8ed1ab_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
...

Together with import IPython; print(IPython.sys_info()) it is quite enough to know what was ran in that session.

Related