how to check which version of nltk, scikit learn installed?
import nltk
is Python syntax, and as such won't work in a shell script.
To test the version of nltk
and scikit_learn
, you can write a Python script and run it. Such a script may look like
import nltk
import sklearn
print('The nltk version is {}.'.format(nltk.__version__))
print('The scikit-learn version is {}.'.format(sklearn.__version__))
# The nltk version is 3.0.0.
# The scikit-learn version is 0.15.2.
Note that not all Python packages are guaranteed to have a __version__
attribute, so for some others it may fail, but for nltk and scikit-learn at least it will work.
For checking the version of scikit-learn in shell script, if you have pip installed, you can try this command
pip freeze | grep scikit-learn
scikit-learn==0.17.1
Hope it helps!
In Windows® systems you can simply try
pip3 list | findstr scikit
scikit-learn 0.22.1
If you are on Anaconda try
conda list scikit
scikit-learn 0.22.1 py37h6288b17_0
And this can be used to find out the version of any package you have installed. For example
pip3 list | findstr numpy
numpy 1.17.4
numpydoc 0.9.2
Or if you want to look for more than one package at a time
pip3 list | findstr "scikit numpy"
numpy 1.17.4
numpydoc 0.9.2
scikit-learn 0.22.1
Note the quote characters are required when searching for more than one word.
Take care.
Try this:
$ python -c "import nltk; print nltk.__version__"