win10 64bit下python NLTK安裝教程
由于最近需要做項目,需要進行分詞等,查了資料之后,發(fā)現python NLTK很強大,于是就想試試看。在網上找了很多安裝資料,都不太完整,下載的時候也總是會出現一點小意外,最后終于也安裝成功了,所以分享下經驗。
初學者,請高手指出不合理的地方。
我的工作站環(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等等。在安裝的時候要注意安裝路徑,最好不要出現中文。
我在安裝第4步的時候出現了一點小問題,執(zhí)行命令后報錯:Python version 2.7 required, which was not found in the registry,于是我又到網上查了資料,解決方法是:
1)自己新建一個register.py文件,在文件中復制黏貼以下內容,然后保存到自己的路徑,我是直接放到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)。出現Python 2.7 is already registered!則表示配置成功。
3)接著,進入Scripts目錄,輸入:easy_install pip,提示安裝成功。
第5步是安裝PyYAML和NLTK。直接在剛才的目錄中輸入:pip install pyyaml nltk,這時會提示安裝是否成功,若安裝成功可以接著下一步。
此時,就可以到IDLE中進行下載NLTK的數據包:
稍等一會,就出現了如下的頁面,彈出如下窗口,即完成了。我是選擇下載了所有的data,你可以根據自己的需要進行下載。要等很久才會完成這個過程,慢慢來,最后就可以測試啦。
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
python Selenium爬取內容并存儲至MySQL數據庫的實現代碼
這篇文章主要介紹了python Selenium爬取內容并存儲至MySQL數據庫的實現代碼,需要的朋友可以參考下2017-03-03Python常用模塊之threading和Thread模塊及線程通信
這篇文章主要介紹了Python常用模塊之threading和Thread模塊及線程通信,文章為圍繞主題的相關內容展開詳細的內容介紹,具有一定的參考價值,需要的朋友看可以參考一下方法2022-06-06PyCharm+Pipenv虛擬環(huán)境開發(fā)和依賴管理的教程詳解
這篇文章主要介紹了PyCharm+Pipenv虛擬環(huán)境作開發(fā)和依賴管理的教程,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-04-04