亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

win10 64bit下python NLTK安裝教程

 更新時間:2018年09月19日 09:43:31   作者:Wendy-lxq  
這篇文章主要為大家詳細介紹了win10 64bit下python NLTK安裝教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下

由于最近需要做項目,需要進行分詞等,查了資料之后,發(fā)現(xiàn)python NLTK很強大,于是就想試試看。在網(wǎng)上找了很多安裝資料,都不太完整,下載的時候也總是會出現(xiàn)一點小意外,最后終于也安裝成功了,所以分享下經(jīng)驗。

初學者,請高手指出不合理的地方。

我的工作站環(huán)境是Win10 64 + Python 2.7.12 64 bit。

按照NLTK上安裝主頁上的指引如下:

Source installation (for 32-bit or 64-bit Windows)
 
1.Install Python: http://www.python.org/download/releases/2.7.3/
2.Install Numpy (optional): http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
3.Install Setuptools: http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe
4.Install Pip: Start>Run... c:\Python27\Scripts\easy_install pip
5.Install PyYAML and NLTK: Start>Run... c:\Python27\Scripts\pip install pyyaml nltk
6.Test installation: Start>All Programs>Python27>IDLE, then type import nltk

前3步的安裝都比較簡單,如果為了更好的編輯,也可以安裝一下編輯軟件,如PyCharm,Sublime text2/3等等。在安裝的時候要注意安裝路徑,最好不要出現(xiàn)中文。

我在安裝第4步的時候出現(xiàn)了一點小問題,執(zhí)行命令后報錯:Python version 2.7 required, which was not found in the registry,于是我又到網(wǎng)上查了資料,解決方法是:

1)自己新建一個register.py文件,在文件中復制黏貼以下內(nèi)容,然后保存到自己的路徑,我是直接放到pyhon的安裝文件夾中;

# 
# 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)Ctrl+R打開cmd,然后進入python的安裝目錄(如果有配置環(huán)境變量的話,就不用這么麻煩了,可以直接命令操作),輸入:python register.py(這個是剛才存錯register.py的路徑,如D:\register.py)。出現(xiàn)Python 2.7 is already registered!則表示配置成功。

3)接著,進入Scripts目錄,輸入:easy_install pip,提示安裝成功。

第5步是安裝PyYAML和NLTK。直接在剛才的目錄中輸入:pip install pyyaml nltk,這時會提示安裝是否成功,若安裝成功可以接著下一步。

此時,就可以到IDLE中進行下載NLTK的數(shù)據(jù)包:

稍等一會,就出現(xiàn)了如下的頁面,彈出如下窗口,即完成了。我是選擇下載了所有的data,你可以根據(jù)自己的需要進行下載。要等很久才會完成這個過程,慢慢來,最后就可以測試啦。

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論