Modulenotfounderror: no module named nltk [Fixed]

Are you facing Modulenotfounderror: no module named nltk error in Python?

This tutorial explains a few steps to fix it as well as why we get this error.

What is Modulenotfounderror: no module named ‘nltk’?

The “ModuleNotFoundError: no module named ‘nltk’” error occurs when the Natural Language Toolkit (NLTK) module is not installed on your system or when it is not found by Python.

Moreover, NLTK is a popular library used for natural language processing and text analysis in Python.

What is the reason of Modulenotfounderror: no module named nltk error?

There are several reasons why you might encounter this error, including:

  • NLTK is not installed on your system.
  • NLTK is installed, but not in the correct location.
  • The NLTK module is corrupted or outdated.
  • Python environment is not set up correctly.

Steps to fix Modulenotfounderror: no module named nltk

To fix this error the following are the steps you can consider.

  1. Install nltk module

    To install NLTK, open your command prompt or terminal and run the following command:

    pip install nltk

    This will install the latest version of NLTK and its dependencies.

    Install nltk

  2. Check nltk Installation

    To check if NLTK is installed correctly, run the following code in your Python environment:

    import nltk

    If NLTK is installed correctly, you should not see any error messages.

  3. Check nltkl data

    NLTK requires additional data to function properly. To download the required data, run the following code in your Python environment:

    This will open the NLTK Downloader GUI, where you can select and download the required data.

    Download nltk

  4. Set Up Python Environment

    If you still encounter the “ModuleNotFoundError: No module named ‘nltk'” error after installing NLTK and its data, it might be due to a problem with your Python environment.

    Ensure that your Python environment is correctly set up and that NLTK is installed in the correct location.

Other Solution Modulenotfounderror no module named nltk

Install nltk in windows

In installing nltk module in windows just do the following:

  1. Open your command prompt.
  2. Type the command pip install nltk and press Enter.

Install nltk in macOS and Linux

Here’s how you can install NLTK (Natural Language Toolkit) on macOS and Linux:

  • Open a terminal window.
  • Install pip (Python package installer) by running the following command:
    • sudo easy_install pip
  • Install NLTK by running the following command:
    • sudo pip install -U nltk

Install nltk module in PyCharm

To install nltk in you can use the IDE of PyCharm itself. Follow the steps we will provide:

  • Head over on “File> Settings> Project> Python Interpreter“.
  • Select the + icon and type nltk.
  • Then click on “Install Package”.

Upon installing the modules of Python in Pycharm, ensure that your IDE is configured in the correct version.

Install nltk in Anconda

The following steps are to install nltk in Anaconda and consider following the guide to fix no module named nltk error.

If you are using Anaconda navigator do this:

  1. Open your Anaconda Navigator.
  2. On “Environments” click it and select your project.
  3. From the search bar to the right type nltk.
  4. Click the nltk package and click on “Apply”.

If you want to install through a command do this:

  1. On windows open the anaconda prompt application.
  2. If you using macOS or Linux, open your terminal.

Run the following command to install the nltk package.

Given ScenarioCommand
If using condaconda install -c anaconda nltk
Use pippip install nltk –upgrade
When using Python 3pip3 install nltk –upgrade
When getting permissions errorsudo pip3 install nltk –upgrade
If you don’t have pip in your PATH environment variablepython -m pip install nltk –upgrade
When using python 3python3 -m pip install nltk –upgrade
When using py aliaspy -m pip install nltk –upgrade
Alternative if you get permissions errorpip install nltk –user –upgrade

Install NLTK in Jupyter Notebook

To install the nltk in Jupyter Notebook consider following the steps below:

  1. Oper your terminal and type Jupyter Notebook.
  2. Open on “New” and then click on “Python 3 (ipykernel)”.jupyter notebook click new ipykernel
  3. Type !pip install nltk and click on “Run”.

Note that the pip install command must begin with an exclamation mark if you use this method.

!pip install nltk –upgrade

After you have input the command, just click run and nltk module should be installed.

If you fetch a permissions error, such as “[WinError: 5] Access is denied”, include the –user option in the installation command.

!pip install nltk –user –upgrade


In conclusion, Modulenotfounderror: no module named nlk is an error raised when the Python code is trying to import the “nlk” module but it can’t be found.

Or the module is not installed or it’s installed in a location where your Python interpreter is not looking for it.

Remember to always keep your Python installation and modules up to date, and to check for missing dependencies if you encounter any issues.

We hope that this guide has helped you fix the “ModuleNotFoundError: No module named ‘nltk'” error in Python. If you have any further questions or concerns, please do not hesitate to reach out to us.

If you are finding solutions to some errors you’re encountering we also have Modulenotfounderror: no module named flask_sqlalchemy.

Leave a Comment