Skip to content

Latest commit

 

History

History
137 lines (89 loc) · 4.16 KB

install.rst

File metadata and controls

137 lines (89 loc) · 4.16 KB

Installing NLTK

NLTK is a Python package. It supports Python 2.6, 2.7 or 3.2+.

If you don't have Python installed you should install it first. We recommend using latest Python (3.4.1 at the time of writing).

Below is a description of how to install NLTK with Python 3.4. There are other ways to install Python and get NLTK working with it (e.g. one can use Anaconda, or install NLTK without virtualenv, or use Python 2.x); please check Wiki for other installation methods.

Preparing the Environment

When the environment is ready, NLTK should install the same regardless of an operating system. How to prepare the environment depends on OS.

Windows 64 bit

TODO: check that it works

  1. Download and install latest minor release of Python 3.4 from https://www.python.org.
  2. Check that the Python is installed correctly: open the terminal and run python3.4 - it should open the Python shell. Press Ctrl-D to close the Python shell.
  3. It is a good practice to use a virtual environment. Create and activate it using the following commands:

    pyvenv my-nltk-env
    my-nltk-env/Scripts/activate.bat
  4. Install numpy. Some of the NLTK modules can be used without numpy, but many of them require numpy; you'll need numpy to follow NLTK book.

    pip install -f https://nipy.bic.berkeley.edu/scipy_installers numpy

    Note

    Installing Numpy can be hard on Windows, especially if a virtual environment is used. For 64 bit Windows there are binary wheels available at https://nipy.bic.berkeley.edu/scipy_installers - they should work without a build environment.

    If for some reason this doesn't work you may consider using Anaconda.

OS X

  1. Download and install latest minor release of Python 3.4 from https://www.python.org. Python 3 installed using http://brew.sh/ is also fine.
  2. Check that the Python is installed correctly: open the terminal and run python3.4 - it should open the Python shell. Press Ctrl-D to close the Python shell.
  3. It is a good practice to use a virtual environment. Create and activate it using the following commands:

    pyvenv ./my-nltk-env
    source ./my-nltk-env/bin/activate
  4. Install numpy. Some of the NLTK modules can be used without numpy, but many of them require numpy; you'll need numpy to follow NLTK book.

    pip install numpy

    Note

    Numpy started to provide binary wheels for OS X; this means 'pip install numpy' should now work fast and without a build environment.

Ubuntu

  1. TODO: install Python 3.4 from https://launchpad.net/~fkrull/+archive/ubuntu/deadsnakes
  2. TODO: install packages needed to build numpy
  3. It is a good practice to use a virtual environment. Create and activate it using the following commands:

    pyvenv ./my-nltk-env
    source ./my-nltk-env/bin/activate
  4. Install numpy. Some of the NLTK modules can be used without numpy, but many of them require numpy; you'll need numpy to follow NLTK book.

    pip install numpy

    Note

    It might take some time to compile numpy.

Installing NLTK

When the environment is ready, NLTK should install the same regardless of an operating system.

  1. Install NLTK:

    pip install nltk
  2. Test installation: run python then type import nltk and press Enter - it shouldn't raise ImportError.

    Note that NLTK was installed in a virtual environment; if you open a new terminal window you should activate the environment again.

  3. NLTK provides additional data resources; you'll need them to follow the NLTK Book and to use some of the NLTK modules. To get the data required for NLTK book run the following command from the command-line:

    python -m nltk.downloader book

    You can also run python -m nltk.downloader and use the GUI to download the data.