python中nltk_python2.7和NLTK安装详细教程
本文為大家分享了python2.7和NLTK安裝教程,具體內(nèi)容如下
系統(tǒng):Windows 7 Ultimate 64-bits
Python 2.7安裝
下載Python 2.7:官網(wǎng)下載地址
安裝
NLTK安裝
1、下載NLTK,下載地址,?安裝。
2、安裝時會出現(xiàn)以下錯誤:Python version 2.7 required, which was not found in the registry。
解決辦法:
(1)新建一個register.py文件,把以下代碼粘貼進(jìn)去,保存到D盤。
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html
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!"
if __name__ == "__main__":
RegisterPy()
(2)開始-運(yùn)行-cmd,把D:\register.py復(fù)制進(jìn)去按回車,出現(xiàn)Python 2.7 is already registered!則表示配置成功。
3、繼續(xù)安裝setuptools
4、安裝Pip:開始-運(yùn)行-D:\Program Files\Python\Scripts\easy_install pip
5、安裝PyYAML和NLTK:開始-運(yùn)行-D:\Program Files\Python\Scripts\pip install pyyaml nltk
6、測試安裝:開始-所有程序-Python 2.7-IDLE(Python GUI),輸入import nltk,無錯誤表示成功。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。
本文標(biāo)題: python2.7和NLTK安裝詳細(xì)教程
本文地址: http://www.cppcns.com/jiaoben/python/240058.html
總結(jié)
以上是生活随笔為你收集整理的python中nltk_python2.7和NLTK安装详细教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python爬虫分析大学排名_Pytho
- 下一篇: python爬虫反爬 对方是如何丧心病狂