To check the versions of multiple libraries in bulk from a Jupyter notebook

 To check the versions of multiple libraries in bulk from a Jupyter notebook, you can use a few handy Python techniques. Here are the best ways to do it:


Method 1: Use pip inside notebook

You can list all installed packages and their versions:

python
!pip list

Method 2: Print versions of specific libraries manually

If you just want to know the versions of specific libraries (e.g., pandas, numpy, sklearn, streamlit, etc.):

python
import pandas as pd import numpy as np import sklearn import streamlit as st print(f"pandas: {pd.__version__}") print(f"numpy: {np.__version__}") print(f"scikit-learn: {sklearn.__version__}") print(f"streamlit: {st.__version__}")

Add more lines as needed for other libraries like joblib, xgboost, lightgbm, etc.


Method 3: Use a helper function for many libraries

If you have a long list of libraries, try this:

python
libs = ['pandas', 'numpy', 'sklearn', 'streamlit', 'matplotlib', 'seaborn', 'xgboost', 'joblib'] for lib in libs: try: mod = __import__(lib) print(f"{lib}: {mod.__version__}") except Exception as e: print(f"{lib}: not installed or version unknown")


No comments

Theme images by tjasam. Powered by Blogger.