how to check which version of nltk, scikit learn i

2020-02-16 07:07发布

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.

7条回答
乱世女痞
2楼-- · 2020-02-16 07:50

You can simply try

pip3 list 

and that would give you a list like this

bleach (2.0.0)
colorama (0.3.9)
cycler (0.10.0)
decorator (4.1.2)
entrypoints (0.2.3)
enum34 (1.1.6)
graphviz (0.8)
html5lib (0.999999999)
ipykernel (4.6.1)
ipython (6.1.0)
ipython-genutils (0.2.0)
ipywidgets (7.0.0)
jedi (0.10.2)
Jinja2 (2.9.6)
  ..........
PyYAML (3.12)
pyzmq (16.0.2)
qtconsole (4.3.1)
scikit-learn (0.19.0)   <------
scipy (0.19.1)
setuptools (36.4.0)
simplegeneric (0.8.1)
   .......

You can visually scan the list to find the version of all installed packages... the list is in alphabetical order, so it is easy to scan.

If you are in Anaconda conda list would do the same for you.

查看更多
登录 后发表回答