python2.7和NLTK安装详细教程
本文为大家分享了python2.7和NLTK安装教程,具体内容如下
系统:Windows7Ultimate64-bits
Python2.7安装
下载Python2.7:官网下载地址
安装
NLTK安装
1、下载NLTK,下载地址, 安装。
2、安装时会出现以下错误:Pythonversion2.7required,whichwasnotfoundintheregistry。
解决办法:
(1)新建一个register.py文件,把以下代码粘贴进去,保存到D盘。
#scripttoregisterPython2.0orlaterforusewithwin32all #andotherextensionsthatrequirePythonregistrysettings # #writtenbyJoakimLoewforSecretLabsAB/PythonWare # #source: #http://www.pythonware.com/products/works/articles/regpy20.htm # #modifiedbyValentineGogichashviliasdescribedinhttp://www.mail-archive.com/distutils-sig@python.org/msg10512.html importsys from_winregimport* #tweakasnecessary 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 ) defRegisterPy(): try: reg=OpenKey(HKEY_CURRENT_USER,regpath) exceptEnvironmentErrorase: try: reg=CreateKey(HKEY_CURRENT_USER,regpath) SetValue(reg,installkey,REG_SZ,installpath) SetValue(reg,pythonkey,REG_SZ,pythonpath) CloseKey(reg) except: print"***Unabletoregister!" return print"---Python",version,"isnowregistered!" return if(QueryValue(reg,installkey)==installpathand QueryValue(reg,pythonkey)==pythonpath): CloseKey(reg) print"===Python",version,"isalreadyregistered!" return CloseKey(reg) print"***Unabletoregister!" print"***YouprobablyhaveanotherPythoninstallation!" if__name__=="__main__": RegisterPy()
(2)开始-运行-cmd,把D:\register.py复制进去按回车,出现Python2.7isalreadyregistered!则表示配置成功。
3、继续安装setuptools
4、安装Pip:开始-运行-D:\ProgramFiles\Python\Scripts\easy_installpip
5、安装PyYAML和NLTK:开始-运行-D:\ProgramFiles\Python\Scripts\pipinstallpyyamlnltk
6、测试安装:开始-所有程序-Python2.7-IDLE(PythonGUI),输入importnltk,无错误表示成功。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。