且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查scikit学习安装了哪个版本的nltk?

更新时间:2023-09-26 17:58:46

import nltk是Python语法,因此无法在Shell脚本中使用.

import nltk is Python syntax, and as such won't work in a shell script.

要测试nltkscikit_learn的版本,您可以编写一个 Python脚本并运行它.这样的脚本可能看起来像

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.

请注意,并非所有Python软件包都保证具有__version__属性,因此对于某些其他软件包可能会失败,但是对于nltk和scikit-learn而言,至少它会起作用.

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.