Windows 64位下python3安装nltk模块
2018-09-19 09:53
633 查看
在网上找了各种安装教程,都没有在python3下安装nltk,于是我自己尝试着安装,算是成功了
1、首先,假设你的python3已经安装好,并且安装了numpy,matplotlib,pandas一些常用的库,当你安装nltk时,我相信你一定具备了一些python的常用技能,所以默认你已经安装了以上常用模块
2、然后,用cmd打开电脑终端,然后输入D:\Python362\Scripts\pip install pyyaml nltk,这样既安装了PyYAML模块,又安装了nltk模块
3、再次,在python3编辑器里输入import nltk按回车,如下图:
如这样你以为nltk就安装成功了那么你就大错特错了,因为还有一步,如果最后一步忽略的话,那么你在用nltk的时候会出现很多错误,具体出现什么样的错误,忘记截图了,后来运行成功后就没有错误了。
4、最后,在python3 shell里面输入一下命令:
按回车,然后就会出现如下窗口:
我是选择默认的下载路径,点击Download,静静的等待它下载完,关闭窗口。
下面进行nltk测试:
sent1 = 'The cat is walking in the bedroom' sent2 = 'A dog was running across the kitchen' from sklearn.feature_extraction.text import CountVectorizer count_vec = CountVectorizer() sentences = [sent1, sent2] print(count_vec.fit_transform(sentences).toarray()) print(count_vec.get_feature_names()) import nltk tokens_l = nltk.word_tokenize(sent1) print(tokens_l)
运行结果如下:
[[0 1 1 0 1 1 0 0 2 1 0] [1 0 0 1 0 0 1 1 1 0 1]] ['across', 'bedroom', 'cat', 'dog', 'in', 'is', 'kitchen', 'running', 'the', 'walking', 'was'] ['The', 'cat', 'is', 'walking', 'in', 'the', 'bedroom']
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- Windows 64位安装Python numpy 安装后导入出错
- Windows64位下各版本Python安装numpy,SciPy,matplotlib,Ipython模块
- Windows 64位下 python3.4.3 安装numpy scipy
- windows(64位)下用GPU版本的mxnet配置(绑定python)+xgboost快速安装使用
- Windows 7 安装64位 Python 2.7.3 开发环境
- Windows下为64位的python3.4.3安装numpy
- Python进阶(四十二)-windows 64位安装Pillow模块替换PIL模块
- Python包numpy、Matplotlib、SciPy在64位Windows上的安装
- Python---64位的windows系统中python的下载与安装
- Windows 64位 Python 2.7 简单安装MySql模块
- python libsvm windows 64位 安装
- 如何在64位的windows平台上安装需要c编译的python扩展库
- python windows64位 python2.7安装twisted
- windows下多个python版本共存,如何在Windows7系统上安装最新的64位Python3.6.2
- windows 7 64位下安装python-2.7.5.amd64.msi 时 installer 报错 2203
- windows 64位安装python2.7
- Windows下Python环境搭建(包括Win7 64位下安装setuptools)
- Windows 10 64位下安装python2模块MySQLdb(MySQL-python)遇到的坑
- windows 64位下Python2.7.5+Ulipad安装及错误解决办法
- Python---64位的windows系统中python的下载与安装