日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

python中nltk_python2.7和NLTK安装详细教程

發(fā)布時(shí)間:2025/4/5 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python中nltk_python2.7和NLTK安装详细教程 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

本文為大家分享了python2.7和NLTK安裝教程,具體內(nèi)容如下

系統(tǒng):Windows 7 Ultimate 64-bits

Python 2.7安裝

下載Python 2.7:官網(wǎng)下載地址

安裝

NLTK安裝

1、下載NLTK,下載地址,?安裝。

2、安裝時(shí)會(huì)出現(xiàn)以下錯(cuò)誤:Python version 2.7 required, which was not found in the registry。

解決辦法:

(1)新建一個(gè)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、測(cè)試安裝:開始-所有程序-Python 2.7-IDLE(Python GUI),輸入import nltk,無錯(cuò)誤表示成功。

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

本文標(biāo)題: python2.7和NLTK安裝詳細(xì)教程

本文地址: http://www.cppcns.com/jiaoben/python/240058.html

總結(jié)

以上是生活随笔為你收集整理的python中nltk_python2.7和NLTK安装详细教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。