How To Check Versions Of NLTK, Scikit-learn And Other Python Libraries

While using certain Python libraries, we should know the version of these libraries as every incremental version comes with an update in the modules.

Here’s how we can do that:

We can run a very simple script  to test the exact version of scikit-learn, Natural Language Toolkit (NLTK) and all other Python libraries.


import nltk
import sklearn
print(‘The nltk version is {}.’.format(nltk.__version__))
print(‘The scikit-learn version is {}.’.format(sklearn.__version__))

2.      $ python -c "import nltk; print nltk.__version__"
3.      You can try this script on Windows:
pip3 list | findstr scikit
4.      On Anaconda: 
conda list scikit
5.      You can find any package using the below script:
pip3 list | findstr scikit
6.      To find the version of multiple packages at once:
pip3 list | findstr "scikit numpy"

Not every package has __version__ attribute, it might fail for others, but it will work for the scikit-learn library and the NLTK library.

What is the difference between conda vs pip3?

Conda installs packages that may contain software written in any language, unlike Pip, it installs Python packages. Pip, for example, requires the installation of a Python interpreter. You can install that by downloading and running an installer or via a system package manager. Conda, on the other hand, may directly install Python packages and the Python interpreter.


It is important to know the version of the library that we are using since there are many frequent changes that happen by way of updates, etc, so we need to be aware of them. In this article, we learned how that awareness level can be achieved.