Python3.6安装NLTK

xiaoxiao2021-02-28  150

#Python3.6安装NLTK ####说明:我在安装NLTK的过程中遇到了一些问题,我是按照《Python自然语言处理》中所说的,进入nltk.org中下载nltk-3.2.4.exe直接双击安装,出了一些问题(如下图) 如果你没有遇到此问题,一路绿灯,那就不用往下看了。 ##过程: ###1.注册Python 在桌面新建一个registry.py写入如下内容(与python2.x不同)

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()

开始-运行-cmd,把python registry.py复制进去按回车,出现Python 3.6 is already registered!则表示配置成功。

###2.安装PyYAML和NLTK 开始-运行-$Python_Home\Scripts\pip install pyyaml nltk 路径随具体情况而定 ###3.验证 打开Python IDLE输入 import nltk nltk.download() 出现

转载请注明原文地址: https://www.6miu.com/read-29914.html

最新回复(0)