【Python】安裝NLTK


1. 安裝NLTK

 安裝比較方便,去nltk.org主頁上就有安裝的詳細步驟。

安裝頁面:http://nltk.org/install.html

記下Linux步驟:

  1. Open Finder>Applications>Utilities>Terminal and type python -V to find out what version of Python is installed
  2. Install Setuptools: Download the corresponding version of Setuptools from http://pypi.python.org/pypi/setuptools (scroll to the bottom, and pick the filename that contains the right version number and which has the extension .egg). Install it by typing sudo sh Downloads/setuptools-...egg, giving the location of the downloaded file.
  3. Install Pip: run sudo easy_install pip
  4. Install Numpy (optional): run sudo pip install -U numpy
  5. Install PyYAML and NLTK: run sudo pip install -U pyyaml nltk
  6. Test installation: run python then type import nltk

 

2. 安裝自帶數據

nltk里有自帶的數據,在idle里用命令

import nltk
nltk.download()

會出來一個框,選擇你要下的數據就行了。不過要網絡狀況好一點的時候,可能會下不下來,多試幾次。

報錯:error with downloaded zip file

原因:網絡不穩定什么的,多試試。

 

3. 安裝matplotlib

matplotlib是一款python的2D繪圖庫,你可以用該庫生成圖、直方圖、功率譜、柱狀圖錯誤圖(errorcharts)散點圖等。有點像octave和matlab下的繪圖,只需要幾行命令即可。

matplotlib的網址:http://matplotlib.org/

 但是安裝matplotlib需要安裝另外一些庫和軟件:

1) Python-dev:  sudo apt-get install python-dev

2) 如果用python setup.py build來build,可能會缺很多庫,如果你是debian/Ubuntu就可以用命令安裝所需要的包

     sudo apt-get build-dep python-matplotlib

這些都安裝完了就可以安裝matplotlib了,用下面的命令:

cd matplotlib
python setup.py build
python setup.py install

 

 

 


免責聲明!

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



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