NLTK 3.2.2 安裝經驗


NLTK 3.2.2 安裝經驗

  1. Nltk 3.2.2要求Python版本是Python2.7 或者Python3.4+。
  2. Nltk 3.2.3 如果是從網站上直接下載程序進行安裝可能會報錯:Python version -32 required, which was not found in the registry,

      原因可能有以下幾方面:

      1)        Python版本不對:重新安裝合適的Python版本

      2)        Python注冊信息未加入到注冊表中

      3)        Python注冊信息不對

      針對后面兩種情況,我們可以直接通過腳本register.py(具體代碼內容見本文后面)建立注冊信息,然后運行該腳本。注冊信息添加成功后重新安裝nltk模塊即可。

  1. Python3.0 以上版本都自帶有pip,可以通過pip快捷安裝nltk的最新版本,但為了保證庫的版本最新,可以先更新pip

      1)        更新pip:py –m pip install –upgrade pip

      2)        安裝nltk: py –m pip install nltk

                 當出現打印消息:successfully installed nltk-3.2.2 six-1.10.0時表示安裝成功。

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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM