How to Install NLTK on PyCharm?

NLTK is a Python library for processing natural languages enabling easy access to “text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning, wrappers for industrial-strength NLP libraries, and an active discussion forum”.

Problem Formulation: Given a PyCharm project. How to install the NLTK library in your project within a virtual environment or globally?

Here’s a solution that always works:

  • Open File > Settings > Project from the PyCharm menu.
  • Select your current project.
  • Click the Python Interpreter tab within your project tab.
  • Click the small + symbol to add a new library to the project.
  • Now type in the library to be installed, in your example "nltk" without quotes, and click Install Package.
  • Wait for the installation to terminate and close all popup windows.

Here’s the installation process as a short animated video—it works analogously for the NLTK library, just type in “nltk” in the search field instead:

Make sure to select only “nltk” because there are many other packages that are not required but also contain the same term (false positives):

Alternatively, you can run the pip install nltk command in your PyCharm “Terminal” view:

$ pip install nltk

The following figure shows how to use pip to install the NLTK package:

NLTK in PyCharm - pip install & checking version

You can check your installation using the following two lines of Python code that print out the version of the package:

import nltk
print(nltk.__version__)

Feel free to check out the following free email academy with Python cheat sheets to boost your coding skills!

To become a PyCharm master, check out our full course on the Finxter Computer Science Academy available for free for all Finxter Premium Members: