In shell script I am checking whether this packages are installed or not, if not installed then install it. So withing shell script:
import nltk
echo nltk.__version__
but it stops shell script at import
line
in linux terminal tried to see in this manner:
which nltk
which gives nothing thought it is installed.
Is there any other way to verify this package installation in shell script, if not installed, also install it.
For checking the version of scikit-learn in shell script, if you have pip installed, you can try this command
Hope it helps!
In my machine which is ubuntu 14.04 with python 2.7 installed, if I go here,
there is a file called
VERSION
.If I do a
cat VERSION
it prints3.1
, which is the NLTK version installed.You can find NLTK version simply by doing:
And similarly for scikit-learn,
I'm using python3 here.
import nltk
is Python syntax, and as such won't work in a shell script.To test the version of
nltk
andscikit_learn
, you can write a Python script and run it. Such a script may look likeNote 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.you may check from a python notebook cell as follows
and
Try this: