本文记录了nltk 3.2.4 环境搭建的方法,供大家参考,具体内容如下
系统环境:win7 32位
python:2.7.13,后改为3.6.1
安装nltk
从网站下载,完成后双击安装,但提示python version -32 required, which was not found in the registry.
从网上搜索到以下解决方案:
新建文件d:\register.py,通过脚本建立注册信息
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#===============register.py====================## #!/usr/bin/env python # -*- coding:utf-8 -*- import sys from _winreg import * # tweak as necessary version = sys.version[: 3 ] installpath = sys.prefix regpath = "software\\python\\pythoncore\\%s\\" % (version) installkey = "installpath" pythonkey = "pythonpath" pythonpath = "%s;%s\\lib\\;%s\\dlls\\" % ( installpath, installpath, installpath ) def registerpy(): try : reg = openkey(hkey_current_user, regpath) except environmenterror as e: try : reg = createkey(hkey_current_user, regpath) setvalue(reg, installkey, reg_sz, installpath) setvalue(reg, pythonkey, reg_sz, pythonpath) closekey(reg) except : print ( "*** unable to register!" ) return print ( "--- python" , version, "is now registered!" ) return if (queryvalue(reg, installkey) = = installpath and queryvalue(reg, pythonkey) = = pythonpath): closekey(reg) print ( "=== python" , version, "is already registered!" ) return closekey(reg) print ( "*** unable to register!" ) print ( "*** you probably have another python installation!" ) registerpy() |
打开cmd,执行
运行安装文件,仍然失败= =(有大神能解决的请私信或留言 谢谢!)
于是放弃了中文版的nlp with python,重投http://www.nltk.org/book/。
安装最新版python3.6.1,cmd中直接执行
1
|
py –m pip install nltk |
安装成功。
在idle中输入命令
1
2
|
>>> import nltk >>>nltk.download() |
终于出现如下nltk downloader界面
下载完毕后,就可以在idle中加载nltk并使用了。
1
|
>>> from nltk.book import * |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/fessigy/article/details/72923382